Build a {@code String} instance by {@code new String(input, "UTF-8")}.
968532
public static String toStringUTF8(byte[] input)
    {
        if (input == null)
        {
            return null;
        }

        try
        {
            return new String(input, "UTF-8");
        }
        catch (UnsupportedEncodingException e)
        {
            // This won't happen.
            return null;
        }
    }
384487
private static String createByteString(byte bytes[])
    {
        StringBuilder sb = new StringBuilder();
        if (bytes == null)
        {
            sb.append("null");
        }
        else
        {
            for (byte b : bytes)
            {
                sb.append(String.format("%02x", b));
            }
        }
        return sb.toString();
    }
773172
def create_string_buffer(init, size=None):
    
    if isinstance(init, (str, unicode)):
        if size is None:
            size = len(init) + 1
        buftype = c_char * size
        buf = buftype()
        buf.value = init
        return buf
    elif isinstance(init, (int, long)):
        buftype = c_char * init
        buf = buftype()
        return buf
    raise TypeError, init
856822
static void writeString(final String value, final DataOutput out)
		throws IOException
	{
		final byte[] bytes = value.getBytes("UTF-8");
		writeInt(bytes.length, out);
		out.write(bytes);
	}
1058221
@Override
	public OUTPUT newInstance() throws FAILURE {
		
		StringBuilder builder = new StringBuilder()
		.append(getClass().getName())
		.append(".newInstance() is unsupported.");
		
		throw new UnsupportedOperationException(builder.toString());
	}
72111
public static String inputStreamToString(InputStream in) {
    final int BUFFER_SIZE = 1024;
    BufferedReader bufferedReader;
    try {
      bufferedReader = new BufferedReader(new InputStreamReader(in, "UTF-8"));
    } catch (UnsupportedEncodingException e) {
      throw new DatasetException(
          "Platform doesn't support UTF-8. It must!", e);
    }
    char[] buffer = new char[BUFFER_SIZE];
    StringBuilder stringBuilder = new StringBuilder(BUFFER_SIZE);
    int bytesRead = 0;
    try {
      while ((bytesRead = bufferedReader.read(buffer, 0, BUFFER_SIZE)) > 0) {
        stringBuilder.append(buffer, 0, bytesRead);
      }
    } catch (IOException e) {
      throw new DatasetException("Error reading from input stream", e);
    }
    return stringBuilder.toString();
  }
640759
public static ReadStreamOld open(String string)
  {
    VfsStringReader ss = new VfsStringReader(string);
    ReadStreamOld rs = new ReadStreamOld(ss);
    try {
      rs.setEncoding("UTF-8");
    } catch (Exception e) {
    }
    //rs.setPath(new NullPath("string"));
    return rs;
  }
455583
@Override
    public Character fromString(Class targetClass, String s)
    {
        try
        {
            if (s == null)
            {
                log.error("Can't convert String " + s + " to character");
                throw new PropertyAccessException("Can't convert String " + s + " to character");
            }

            Character c = null;
            if (s.length() == 1)
            {
                c = s.charAt(0);
            }
            else
            {
                c = Character.MIN_VALUE;
            }

            return c;
        }
        catch (NumberFormatException e)
        {
            log.error("Number format exception caught,Caused by {}.", e);
            throw new PropertyAccessException(e);
        }
    }
1178169
private static InputSource stringToSource(String str) {
        InputSource is = new InputSource(new StringReader(str));
        is.setEncoding("UTF-8");
        return is;
    }
678852
def write_string(self, string):
        
        buf = bytes(string, 'UTF-8')
        length = len(buf)
        self.write_int(length)
        self.write(buf)
1203156
public static String encode(String input)
    {
        try
        {
            return URLEncoder.encode(input, "UTF-8");
        }
        catch (UnsupportedEncodingException e)
        {
            // This never happens.
            return input;
        }
    }
181712
public static String convertCharsToXml(String input) {
		StringBuffer result = new StringBuffer();
		for(int i=0; i<input.length(); i++) {
			switch(input.charAt(i)) {
				case '<':	result.append("&lt;"); break;
				case '>':	result.append("&gt;"); break;
				case '"':	result.append("&quot;"); break;
				case '\'':	result.append("&apos;"); break;
				case '&':	result.append("&amp;"); break;
				default:	result.append(input.charAt(i));
			}
		}
		return result.toString().trim();
	}
991057
public void updateUtf8(String string) {
        if (string != null) {
            byte[] bytes;
            try {
                bytes = string.getBytes("UTF-8");
            } catch (UnsupportedEncodingException e) {
                throw new RuntimeException(e);
            }
            update(bytes, 0, bytes.length);
        }
    }
1034346
@SuppressLint("DefaultLocale")
    private static String toLowerCaseFirstOne(String string) {
        int length = string.length();

        if (length == 0 || Character.isLowerCase(string.charAt(0))) {
            return string;
        } else if (length == 1) {
            return string.toLowerCase();
        } else {
            return (new StringBuilder())
                    .append(Character.toLowerCase(string.charAt(0)))
                    .append(string.substring(1)).toString();
        }
    }
633563
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;
    }
23510
public String convertToJavaString(String input, boolean useUnicode) {
		int length = input.length();
		StringBuilder result = new StringBuilder(length + 4);
		for (int i = 0; i < length; i++) {
			escapeAndAppendTo(input.charAt(i), useUnicode, result);
		}
		return result.toString();
	}
720836
def create_string(self, value: str) -> String:
        
        self.append((
            8,
            self.create_utf8(value).index
        ))
        return self.get(self.raw_count - 1)