public void printString(String v,int offset,int length) throws IOException {
  for (int i=0; i < length; i++) {
    char ch=v.charAt(i + offset);
    if (ch == '<') {
      os.write('&');
      os.write('#');
      os.write('6');
      os.write('0');
      os.write(';');
    }
 else     if (ch == '&') {
      os.write('&');
      os.write('#');
      os.write('3');
      os.write('8');
      os.write(';');
    }
 else     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));
    }
  }
}

public void printString ( String v , int offset , int length ) throws IOException { for ( int i = 0 ; i < length ; i ++ ) { char ch = v . charAt ( i + offset ) ; if ( ch == '<' ) { os . write ( '&' ) ; os . write ( '#' ) ; os . write ( '6' ) ; os . write ( '0' ) ; os . write ( ';' ) ; } else if ( ch == '&' ) { os . write ( '&' ) ; os . write ( '#' ) ; os . write ( '3' ) ; os . write ( '8' ) ; os . write ( ';' ) ; } else 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 ) ) ; } } }
prints a string to the stream , encoded as utf - 8
