Skip to content

Instantly share code, notes, and snippets.

@aphexmunky
Created February 11, 2013 12:50
Show Gist options
  • Save aphexmunky/4754257 to your computer and use it in GitHub Desktop.
Save aphexmunky/4754257 to your computer and use it in GitHub Desktop.
Converting to a specific charset
private String toSingleByteISO8859(String unicode) {
if (unicode != null) {
try {
ByteBuffer encoded = ISO_8859_1.encode(unicode);
String convertedString = new String(encoded.array(), ISO_8859_1.displayName());
return convertedString;
} catch (UnsupportedEncodingException e) {
logger.error("Problems converting to ISO-8859-1", e);
return "?";
}
}
return unicode;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment