public void printString(String v) throws IOException {
  int len=v.length();
  for (int i=0; i < len; i++) {
    char ch=v.charAt(i);
switch (ch) {
case '<':
      print("&lt;");
    break;
case '&':
  print("&amp;");
break;
case '\r':
print("&#13;");
break;
default :
if (ch < 0x80) os.write(ch);
 else if (ch < 0x800) {
os.write(0xc0 + ((ch >> 6) & 0x1f));
os.write(0x80 + (ch & 0x3f));
}
 else {
os.write(0xe0 + ((ch >> 12) & 0xf));
os.write(0x80 + ((ch >> 6) & 0x3f));
os.write(0x80 + (ch & 0x3f));
}
break;
}
}
}

public void printString ( String v ) throws IOException { int len = v . length ( ) ; for ( int i = 0 ; i < len ; i ++ ) { char ch = v . charAt ( i ) ; switch ( ch ) { case '<' : print ( "&lt;" ) ; break ; case '&' : print ( "&amp;" ) ; break ; case '\r' : print ( "&#13;" ) ; break ; default : if ( ch < 0x80 ) os . write ( ch ) ; else if ( ch < 0x800 ) { os . write ( 0xc0 + ( ( ch > > 6 ) & 0x1f ) ) ; os . write ( 0x80 + ( ch & 0x3f ) ) ; } else { os . write ( 0xe0 + ( ( ch > > 12 ) & 0xf ) ) ; os . write ( 0x80 + ( ( ch > > 6 ) & 0x3f ) ) ; os . write ( 0x80 + ( ch & 0x3f ) ) ; } break ; } } }
prints a string to the stream , properly encoded .
