code: protected static byte[] encodeString(String string) {
          Element element = getStringCache().get(string);
          byte[] encoded = (element == null ? null : (byte[]) element.getObjectValue());
          if (encoded == null) {
              ByteBuffer buf = AMF.CHARSET.encode(string);
              encoded = new byte[buf.limit()];
              buf.get(encoded);
              getStringCache().put(new Element(string, encoded));
          }
          return encoded;
      }
docs: Encode string.
  
  @param string
  string to encode
  @return encoded string