Created
February 11, 2013 12:50
-
-
Save aphexmunky/4754257 to your computer and use it in GitHub Desktop.
Converting to a specific charset
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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