I changed a file in Orbeon Forms, and the next time I load the page, I get an error message saying Invalid byte 2 of a 3-byte UTF-8 sequence. How can I solve this p
Had same problem.
Problem > I'm getting X509 certificate values (multiple encoding source) to generate a PDF report. The PDF is generated throught a webservice that waits for an UTF-8 xml request and I've to reencode the values before marshalling.
Solution > http://fabioangelini.wordpress.com/2011/08/04/converting-java-string-fromto-utf-8/
Using this class:
public class StringHelper {
// convert from UTF-8 -> internal Java String format
public static String convertFromUTF8(String s) {
String out = null;
try {
out = new String(s.getBytes("ISO-8859-1"), "UTF-8");
} catch (java.io.UnsupportedEncodingException e) {
return null;
}
return out;
}
// convert from internal Java String format -> UTF-8
public static String convertToUTF8(String s) {
String out = null;
try {
out = new String(s.getBytes("UTF-8"), "ISO-8859-1");
} catch (java.io.UnsupportedEncodingException e) {
return null;
}
return out;
}
}
Usage:
//getSummaryAttMap() returns a HashMap
String value = (String) getSummaryAttMap().get(key);
if(value != null)
value = StringHelper.convertToUTF8(value);
else
value = "";