Java Utililty Methods UTF from

List of utility methods to do UTF from

Description

The list of methods to do UTF from are organized into topic(s).

Method

StringtoUTF(String inpara)
to UTF
char temchr;
int ascchr;
int i;
String rtstr = new String("");
if (inpara == null) {
    inpara = "";
for (i = 0; i < inpara.length(); i++) {
...
StringToUTF(String s)
Converts String to UTF-8 String.
int i = 0;
StringBuffer stringbuffer = new StringBuffer();
for (int j = s.length(); i < j; i++) {
    int c = (int) s.charAt(i);
    if ((c >= 1) && (c <= 0x7f)) {
        stringbuffer.append((char) c);
    if (((c >= 0x80) && (c <= 0x7ff)) || (c == 0)) {
...
byte[]toUTF(String str)
to UTF
if (str == null) {
    return null;
if (str.length() == 0) {
    return NO_BYTES;
try {
    return str.getBytes(UTF8);
...
byte[]toUTF(String... str)
to UTF
ByteArrayOutputStream b = new ByteArrayOutputStream();
DataOutputStream out = new DataOutputStream(b);
try {
    for (String s : str)
        out.writeUTF(s);
} catch (IOException e) {
return b.toByteArray();
...
inttoUTF8(byte[] outputBuffer, String string, char[] workingBuffer)
to UTF
if (string == null) {
    return 0;
} else {
    int strlen = string.length();
    char[] charr = null;
    if (workingBuffer == null || strlen > workingBuffer.length) {
        charr = new char[strlen];
    } else {
...
byte[]toUtf8(final String string)
to Utf
try {
    return string.getBytes(UTF8_STRING);
} catch (UnsupportedEncodingException e) {
    throw Throwables.propagate(e);
StringtoUtf8(String hex)
Method converts hex string into utf8 string
String result = "";
int i = 0, length = hex.length();
if (hex.substring(0, 2).equals(HEX_PREFIX)) {
    i = 2;
for (; i < length; i += 2) {
    int code = Integer.parseInt(hex.substring(i, i + 2), 16);
    result += Character.toString((char) code);
...
StringtoUTF8(String oldStr)
to UTF
return conversion(oldStr, "utf-8");
StringtoUtf8(String s)
to Utf
StringBuffer sb = new StringBuffer();
for (int i = 0; i < s.length(); i++) {
    char c = s.charAt(i);
    if (c >= 0 && c <= 255) {
        sb.append(c);
    } else {
        byte[] b;
        try {
...
byte[]toUTF8(String s)
to UTF
return s.getBytes(StandardCharsets.UTF_8);