code: public void writeString(String value)
          throws IOException
      {
          if (value == null) {
              os.write('N');
          }
          else {
              int length = value.length();
              int offset = 0;
  
              while (length > 0x8000) {
                  int sublen = 0x8000;
  
                  // chunk can't end in high surrogate
                  char tail = value.charAt(offset + sublen - 1);
  
                  if (0xd800 <= tail && tail <= 0xdbff)
                      sublen--;
  
                  os.write('s');
                  os.write(sublen >> 8);
                  os.write(sublen);
  
                  printString(value, offset, sublen);
  
                  length -= sublen;
                  offset += sublen;
              }
  
              os.write('S');
              os.write(length >> 8);
              os.write(length);
  
              printString(value, offset, length);
          }
      }
docs: Writes a string value to the stream using UTF-8 encoding.
  The string will be written with the following syntax:
  
  <code><pre>
  S b16 b8 string-value
  </pre></code>
  
  If the value is null, it will be written as
  
  <code><pre>
  N
  </pre></code>
  
  @param value the string value to write.