docs: public static String encode (String string)
      {
          if (string == null)
          {
              return "";
          }
  
          StringBuilder sb = null;
          char c;
          for (int i = 0; i < string.length (); ++i)
          {
              c = string.charAt(i);
              if (((int)c) >= 0x80)
              {
                  if( sb == null )
                  {
                      sb = new StringBuilder( string.length()+4 );
                      sb.append( string.substring(0,i) );
                  }
                  //encode all non basic latin characters
                  sb.append("&#");
                  sb.append((int)c);
                  sb.append(";");
              }
              else if( sb != null )
              {
                  sb.append(c);
              }
          }
  
          return sb != null ? sb.toString() : string;
      }