Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

converting UTF-8 data into CP1256 (Windows)

807607Dec 4 2006 — edited Dec 4 2006
Hello,

i want to convert utf-8 encoded data into cp1256 and save this to a new file but it doesn�t work :( What do i wrong?

try {
Charset csTransformTo=Charset.forName("CP1256");
Charset csTransformFrom=Charset.forName("UTF-8");

out = new BufferedWriter(new OutputStreamWriter(
new FileOutputStream(fTarget), csTransformTo.name()));

byte[] arr=sbCSVData.toString().getBytes(csTransformFrom.name());
String strIso=new String(arr, csTransformTo.name());

out.write(strIso);
out.close();
} catch (UnsupportedEncodingException e) {
m_catLog.error("Error! Encoding is not supported", e);
} catch (IOException e) {
m_catLog.error("I/O Error!", e);
}

greetings
oase
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 1 2007
Added on Dec 4 2006
9 comments
313 views