Java UTF from toUTF8FromLatin1(byte[] outputBuffer, String string)

Here you can find the source of toUTF8FromLatin1(byte[] outputBuffer, String string)

Description

Encode the string into UTF8, assume the original string is ISO-8859-1

License

Open Source License

Parameter

Parameter Description
outputBuffer buffer for the encoded number
string The String to be encoded

Return

the length of the encoded string

Declaration

public static int toUTF8FromLatin1(byte[] outputBuffer, String string) 

Method Source Code

//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;
    }
}

Related

  1. toUtf8(String texto)
  2. toUTF8ByteArray(String s)
  3. toUtf8ByteArray(String source)
  4. toUtf8Code(char utf16)
  5. toUtf8Codes(String str)
  6. toUTF8k(String in)
  7. toUtf8Path(String path)
  8. toUTF8String(byte[] b, int offset, int length)
  9. toUtf8String(String source)