PuneetKSaxena
asked on
Write Russian chars in a xml file
HI ,
I want to read and write russian chars in a xml file from Java code
When i try , encoding="UTF-8", I'm getting ?????????? in xml file
How can i read and write russian chars in Java
Any help in this regard will be highly appreciated
Thanks and Regards
Puneet
I want to read and write russian chars in a xml file from Java code
When i try , encoding="UTF-8", I'm getting ?????????? in xml file
How can i read and write russian chars in Java
Any help in this regard will be highly appreciated
Thanks and Regards
Puneet
can u post your current code
Save your xml-file as utf-8 and change the first line into:
<?xml version="1.0" encoding="UTF-8" ?>
<?xml version="1.0" encoding="UTF-8" ?>
Possible you were using a font before that didn't have those characters in it? Some fonts only have certain characters available.
ASKER
Hi,
I'm reading a html file which contains russian chars, through URL connection (code snippet as below).
Now after parsing this html(which contains russian chars), i'm constrcuting a xml which contains russian chars.
When i view this xml, the russian chars are coming as ?????????, so i'm not able to understand anything from this.
Now i've to use this xml file in Adobe Flex, which again gives me ????????
Hope it clarifies
I'm reading a html file which contains russian chars, through URL connection (code snippet as below).
Now after parsing this html(which contains russian chars), i'm constrcuting a xml which contains russian chars.
When i view this xml, the russian chars are coming as ?????????, so i'm not able to understand anything from this.
Now i've to use this xml file in Adobe Flex, which again gives me ????????
Hope it clarifies
try {
urlIviewPath =new URL(strIviewURLPath+ "&j_user="+ strUserId "&j_password="+ strPassword);
urlIviewPath = Util.encodeUrl(urlIviewPath);//encode the russian chars in URL
urlConnection = urlIviewPath.openConnection();
urlConnection.connect();
br =new BufferedReader(new InputStreamReader( urlConnection.getInputStream(), "UTF-8"));
} catch (RuntimeException e2) {
}
are you sure its utf8, whats the encoding when you load with browser?
how do oyou write them, make sure you use UTF8 there as well
how do oyou write them, make sure you use UTF8 there as well
ASKER
Whille writing xml i'm using
<?xml version="1.0" encoding="UTF-8" ?>.
<?xml version="1.0" encoding="UTF-8" ?>.
try to use
<?xml version="1.0" encoding="UTF-16" ?>.
<?xml version="1.0" encoding="UTF-16" ?>.
You must read the page in the correct encoding and preserve that encoding when you write it to xml, which you should do with an OutputStreamWriter
http://java.sun.com/javase/6/docs/api/java/io/OutputStreamWriter.html#OutputStreamWriter(java.io.OutputStream,%20java.lang.String)
You need to view the results with a program that supports that encoding, and (afaik) that doesn't include a Windows console for UTF-8
http://java.sun.com/javase/6/docs/api/java/io/OutputStreamWriter.html#OutputStreamWriter(java.io.OutputStream,%20java.lang.String)
You need to view the results with a program that supports that encoding, and (afaik) that doesn't include a Windows console for UTF-8
final String ENCODING = urlConnection.getContentEncoding();
br = new BufferedReader(new InputStreamReader(urlConnection.getInputStream(), ENCODING));
ASKER
Thats works for me . But now in xml instead of ???????? i'm getting chars like ÃʄĄ?Ñ?úøù/ÃÅ ¸Ã¾ тøÿу
Any suggestion :)
Any suggestion :)
so you change the write encoding as I suggested earlier? If so, what did u change it to?
And have you checked how the page is encoded?
You haven't answered my earlier question about how you are reading it with. You need to use something that supports displaying russian and has an appropriate font.
does it look the same in flex?
And have you checked how the page is encoded?
You haven't answered my earlier question about how you are reading it with. You need to use something that supports displaying russian and has an appropriate font.
does it look the same in flex?
>>But now in xml instead of ???????? i'm getting chars like ÃÂ
Well unfortunately, i can't read that here ;-). Can you post a screenshot, showing your application window?
Well unfortunately, i can't read that here ;-). Can you post a screenshot, showing your application window?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
make sure what you are viewing with and the font it is using supports russian