Java-to-native string mapping (using direct ByteBuffer)
@param string
@return native string
194633
public static ByteBuffer s2bb(String string) {
        if (string == null) {
            return null;
        }
        byte[] stringBytes = string.getBytes(UTF8);
        ByteBuffer allBytes = ByteBuffer.allocateDirect(stringBytes.length);
        allBytes.position(0);
        allBytes.put(stringBytes);
        return allBytes;
    }
1368988
static String decodeString(ByteBuf in) throws UnsupportedEncodingException {
        if (in.readableBytes() < 2) {
            return null;
        }
        //int strLen = Utils.readWord(in);
        int strLen = in.readUnsignedShort();
        if (in.readableBytes() < strLen) {
            return null;
        }
        byte[] strRaw = new byte[strLen];
        in.readBytes(strRaw);

        return new String(strRaw, "UTF-8");
    }
999828
@Override
  public Utf8 readString(Utf8 old) throws IOException {
    ByteBuffer stringBytes = readBytes(null);
    return new Utf8(stringBytes.array());
  }
306774
private static byte[] convert_to_bytes(String string) {
        if (null == string) {
            return null;
        }
        if (0 == string.length()) {
            return EMPTY_BYTE_ARRAY;
        }
        try {
            return string.getBytes(STRING_CONVERSION_CODE);
        } catch (UnsupportedEncodingException e) {
            logger.logp(Level.SEVERE, PasswordUtil.class.getName(), "convert_to_bytes", "PASSWORDUTIL_UNSUPPORTEDENCODING_EXCEPTION", e);
            return null;
        }
    }
367620
function bufferToString(buffer) {
	        // base64-arraybuffer
	        var bytes = new Uint8Array(buffer);
	        var base64String = '';
	        var i;

	        for (i = 0; i < bytes.length; i += 3) {
	            /*jslint bitwise: true */
	            base64String += BASE_CHARS[bytes[i] >> 2];
	            base64String += BASE_CHARS[(bytes[i] & 3) << 4 | bytes[i + 1] >> 4];
	            base64String += BASE_CHARS[(bytes[i + 1] & 15) << 2 | bytes[i + 2] >> 6];
	            base64String += BASE_CHARS[bytes[i + 2] & 63];
	        }

	        if (bytes.length % 3 === 2) {
	            base64String = base64String.substring(0, base64String.length - 1) + '=';
	        } else if (bytes.length % 3 === 1) {
	            base64String = base64String.substring(0, base64String.length - 2) + '==';
	        }

	        return base64String;
	    }
750210
static String toFormattedString(final String iban) {
        final StringBuilder ibanBuffer = new StringBuilder(iban);
        final int length = ibanBuffer.length();

        for (int i = 0; i < length / 4; i++) {
            ibanBuffer.insert((i + 1) * 4 + i, ' ');
        }

        return ibanBuffer.toString().trim();
    }
803464
public static byte[] toByteArray(String string) {
    EnsureUtil.ensureActiveCommandContext("StringUtil.toByteArray");
    ProcessEngineConfigurationImpl processEngineConfiguration = Context.getProcessEngineConfiguration();
    return toByteArray(string, processEngineConfiguration.getProcessEngine());
  }
567429
public static HttpString tryFromString(String string) {
        HttpString cached = Headers.fromCache(string);
        if(cached != null) {
            return cached;
        }
        final int len = string.length();
        final byte[] bytes = new byte[len];
        for (int i = 0; i < len; i++) {
            char c = string.charAt(i);
            if (c > 0xff) {
                return null;
            }
            bytes[i] = (byte) c;
        }
        return new HttpString(bytes, string);
    }
796100
private function convertToWindowsCharset($string)
    {
        $charset = mb_detect_encoding(
            $string,
            "UTF-8, ISO-8859-1, ISO-8859-15",
            true
        );

        $string = mb_convert_encoding($string, "Windows-1252", $charset);
        return $string;
    }
97313
public static ByteBuffer fromUtf8String(CharSequence utfString) {
        if (utfString == null || utfString.length() == 0) {
            return Buffers.EMPTY_BYTE_BUFFER;
        } else {
            return ByteBuffer.wrap(utfString.toString().getBytes(StandardCharsets.UTF_8));
        }
    }
325596
@Pure
	@Inline(value = "new String(Base64Coder.encode(($1).getBytes()))", imported = {Base64Coder.class})
	public static String encodeString(String string) {
		return new String(encode(string.getBytes()));
	}
1339441
public static byte[] getBytesUTF8(String string)
    {
        if (string == null)
        {
            return null;
        }

        try
        {
            return string.getBytes("UTF-8");
        }
        catch (UnsupportedEncodingException e)
        {
            // This never happens.
            return null;
        }
    }
26523
public static ByteBuffer toByteBuffer(String s) {
        ByteBuffer buffer = ByteBuffer.allocateDirect(s.length());
        buffer.put(s.getBytes(UTF_8));
        buffer.flip();
        return buffer;
    }
715054
function stringToBuffer(str) {
    var buf = new Buffer(str.length);
    for (var i = 0; i < buf.length; i++) {
      buf.writeUInt8(str.charCodeAt(i), i);
    }
    return buf;
  }
1107829
public static ByteBuffer bytes(String s)
	    {
	    	if(s==null)
	    		return null;
	        return ByteBuffer.wrap(s.getBytes(UTF_8));
	    }
1178358
public static String javaStringEscape(@NonNull String string) {
      StringBuilder b = new StringBuilder();
      for (char c : string.toCharArray()) {
         if (c >= 128) {
            b.append("\\u").append(String.format("%04X", (int) c));
         } else {
            b.append(c);
         }
      }
      return b.toString();
   }
387826
public static String toUpperCase(String string) {
    int length = string.length();
    for (int i = 0; i < length; i++) {
      if (isLowerCase(string.charAt(i))) {
        char[] chars = string.toCharArray();
        for (; i < length; i++) {
          char c = chars[i];
          if (isLowerCase(c)) {
            chars[i] = (char) (c & 0x5f);
          }
        }
        return String.valueOf(chars);
      }
    }
    return string;
  }