Here you can find the source of toUTF8FromLatin1(byte[] outputBuffer, String string)
string
into UTF8, assume the original string is ISO-8859-1
Parameter | Description |
---|---|
outputBuffer | buffer for the encoded number |
string | The String to be encoded |
public static int toUTF8FromLatin1(byte[] outputBuffer, String string)
//package com.java2s; public class Main { /**/* w w w . ja va 2s .c o m*/ * Encode the <code>string</code> into UTF8, assume the original string is ISO-8859-1 * * @param outputBuffer buffer for the encoded number * @param string The String to be encoded * @return the length of the encoded string */ public static int toUTF8FromLatin1(byte[] outputBuffer, String string) { if (string == null) return 0; int len = string.length(); for (int i = 0; i < string.length(); i++) { outputBuffer[i] = (byte) string.charAt(i); } return len; } }