UTF-8 (8-bit UCS/Unicode Transformation Format) is a variable-length character encoding for Unicode. It is able to represent any character in the Unicode standard, yet the initial encoding of byte codes and character assignments for UTF-8 is backwards compatible with ASCII. For these reasons, it is steadily becoming the preferred encoding for e-mail, web pages.
Shift JIS is a character encoding for the Japanese language.
This is a sample example of using encoding in Java.
filename = new StringBuilder();
private static final String DEFAULT_CHARSET = "ISO-8859-1";
try {
filename.append(new String(getText("campaign.download.filename.prefix").getBytes("UTF-8"), DEFAULT_CHARSET))
.append("-")
.append(sdf.format(now))
.append("-")
.append(new String(getCampaign().getName().toLowerCase().replace(" ", "-").getBytes("UTF-8"), DEFAULT_CHARSET))
.append(".csv");
} catch (UnsupportedEncodingException e) {
addActionError(getText("error.advertisementCsv.failedToDownload"));
return INPUT;
}
Tuesday, July 22, 2008
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment