I wrote this function, the last line seems wrong* but it actually works. Can someone explain how does this stuff work ?
function convertEncoding(str,from,to) {
var charSetObj = createobject("java", "java.nio.charset.Charset");
var e_to = charsetObj.forName(from);
var e_from = charsetObj.forName(to);
return e_from.decode(e_to.encode(str)).toString();
}
I am on BlueDragon 7 and 7.1JX (not the open source)
I was inspired from this function : http://acoderslife.com/index.cfm/blog/Converting-Text-From-UTF-8-to-ISO-8859-1
* It seems that our last action is to work with the From encoding. It should be From.decode(string) and then To.encode(decoded_string)