public void writeString(String s)
    throws IOException {
    String escapedString = escapeString(s);
    
    if (trace == API_TRACE_DETAILED) {
      Log.current.println("writeString = \"" + escapedString + "\"");
    }
    
    if (StringUtils.is7BitASCII(escapedString))   write(CFASL_STRING);
    else write(CFASL_UNICODE_STRING);
    
    byte[] bytes = escapedString.getBytes("UTF-8");
    
    writeInt(bytes.length);
    write(bytes);
  }