This week's book giveaway is in the General Computing forum.
We're giving away four copies of Emmy in the Key of Code and have Aimee Lucido on-line!
See this thread for details.
Win a copy of Emmy in the Key of Code this week in the General Computing forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Paweł Baczyński
  • Piet Souris
  • Vijitha Kumara

Write Japanese characters to CSV

 
Ranch Hand
Posts: 279
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In my JSP I am doing the following

the String results contain comma seperated values with Japanese characters in them. We need to write these Japanese characters to CSV. For this we have a JSP page called load_csv.jsp. Here are its contents

this works fine for English characters but Japanese characters are displayed as junk characters in CSV. Please help.
 
Rancher
Posts: 43011
76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What do you mean by "in CSV"? Where are you looking at this file?

The problem is that CSV files have no way to specify an encoding. So you need to know what encoding is used when the files are created, and then tell whatever program you're using to look at the CSV which encoding it should use.
 
Anjali S Sharma
Ranch Hand
Posts: 279
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by Ulf Dittmer:
What do you mean by "in CSV"? Where are you looking at this file?



I am opening the CSV file in MS excel
 
Anjali S Sharma
Ranch Hand
Posts: 279
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Even if I create an xls file using
<%@ page contentType="application/vnd.ms-excel; charset=UTF-8" %>

and
response.setHeader("Content-Disposition", "attachment;filename=searchresul.xls");

junk characters are displayed for Japanese characters. However, english characters continue to be displayed fine. I have tried with both UTF-8 and Shift_JIS charset
 
Anjali S Sharma
Ranch Hand
Posts: 279
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is an interesting thing that I observed. If I right click on the CSV file and select "Open with --> Word" then the word application asks me
"Select the encoding that makes your document readable". If I select "Unicode (UTF-8)", Japanese characters appear perfectly fine. But why doesn't this happen in excel as that is also UTF-8 compliant since I can type japanese characters into the same excel file.
 
roses are red, violets are blue. Some poems rhyme and some are a tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!