dcsimg
conversion from UTF-16 to UTF-8
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Alok_Rai
Posted On:   Sunday, January 11, 2004 06:58 AM

Hi!


I have XML file which is in UTF-16 or Cp1252 format, when i read, do not get anything, but question marks(?). How can I convert to UTF-8.


Thanks

Alok

Re: conversion from UTF-16 to UTF-8

Posted By:   Stephen_Ostermiller  
Posted On:   Wednesday, January 14, 2004 04:59 PM


Reader in = new InputStreamReader(new FileInputStream("myutf16file.xml"),"UTF-16");
Writer out = new OutputStreamWriter(new FileOutputStream("myutf8file.xml"),"UTF-8");
char[] buffer = new char[1024];
int read;
while((read = in.read(buffer)) != -1){
out.write(buffer,0,read);
}
in.close();
out.flush();
out.close();
About | Sitemap | Contact