简体   繁体   中英

Print HTML entities from CSV file

Using JSP on a Tomcat I need to load a CSV file and then create an XML output for it to show be shown in the screen. My problem is that sometime this CSV file has special characters like ç, á, é, ó, etc. And in the Web Output (screen) I need to print the ISO-8859-1 entities equivalency, say, instead of ç I need to show ç

So word açucar needs to be shown as: açucar

I can read the CSV file but can't figure out how to tell JSP to print those html entities as I need to.

So if CSV file is:

product;quantity;value

açucar;5723;7.00;

I need to print in my screen something like:

 <item> <product>a&amp;#xe7;ucar</product> <quantity>5723</quantity> <value>7.00</value> </item> 

Any idea how to do this?

Why can't you just use UTF-8 or something like that? Surely any web browser should accept it.

Otherwise, you might want to have a look at this: Recommended method for escaping HTML in Java

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM