Advertisement
Advertisement


How to convert TIS-620 string to UTF-8 string in Java?


Question

How do I convert TIS-620 (the extended ASCII Thai Character code page) string to UTF-8 string in Java?

2015/02/28
1
0
2/28/2015 2:26:35 AM


private byte[] convertTis620ToUTF8(byte[] encoded)
{
    try
    {
        String theString = new String(encoded, "TIS620");
        return theString.getBytes("UTF-8");
    } 
    catch(UnsupportedEncodingException uee)
    {
        /* Didn't work out */
    }
}

...

byte[] utf8 = convertTis620ToUTF8(tis620);

Also, you might need to put charsets.jar on your classpath to support the TIS620 encoding.

2009/04/23

Source: https://stackoverflow.com/questions/246489
Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Email: [email protected]