• Post Reply Bookmark Topic Watch Topic
  • New Topic

Spanish character in the string  RSS feed

 
Ranch Hand
Posts: 33
Java Oracle Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I have issue with spanish characters in java string. I have a content in a file and when i try to transform it to java object using InputStreamReader, the output of some string is "cómo" which should be "cómo".

when i try to display the value in browser it is displaying entity(ó) instead of literal (ó).

Could you please help me to resolve this.

Thanks-Arun

 
arunseege paramashivappa
Ranch Hand
Posts: 33
Java Oracle Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
m transforming using

Transformer transformer = TransformerFactory.newInstance().newTransformer(new StreamSource(xslUrl.openStream()));

// transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8"); // i tried this even then it didnt work thats why i commented this line of code

StringWriter sw = new StringWriter();
transformer.transform(new JDOMSource(emailDoc), new StreamResult(sw));
 
Sheriff
Posts: 22846
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In that code fragment you simply send the result of your transformation to a String. But you're complaining about how something appears in the browser. So there must be a process which sends that String to the browser. you should consider the possibility that the String is being converted to bytes in an incorrect way at some point.

To me it looks like the data is being sent to the browser as UTF-8, but the header says that page is encoded in some other charset. Although you've just described what you saw as "the output of some string", which I have no idea what that means in reality. A more complete description of the problem would be helpful. Including such things as what encoding you used in that InputStreamReader, what encoding the file was written in, where the transformation fits into the picture, why your transformer's output gets sent to a String, and so on.

Perhaps you ought to just stick with the code which produces the HTML entity, since at least that looks correct in the browser.

 
arunseege paramashivappa
Ranch Hand
Posts: 33
Java Oracle Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks paul,

This worked for me

transformer.setOutputProperty(OutputKeys.METHOD, "xml");
transformer.setOutputProperty(OutputKeys.ENCODING, "ISO-8859-1");


thanks-Arun
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!