Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / First Aid / May 2008

Tip: Looking for answers? Try searching our database.

Help on setting UTF8 characterset

Thread view: 
Sandy80 - 27 May 2008 11:32 GMT
Hi,

I have a batch program that is used for formatting some data. The
program uses a java class to take an input as a .xls file, formats the
data from that file and converts it into a .csv file.

The issue that I am facing is that some data in the .xls file is not
represented correctly in the .csv file. For example data like "Dékán"
in the .xls sheet is represented like "Dékán" in the formatted file.

I wanted to know how to set the character set to UTF8 in the java
class so that it represents the data correctly even after the
formatting.

Any help would be appreciated.

Regards,
Sandy
RedGrittyBrick - 27 May 2008 13:18 GMT
> Hi,
>
[quoted text clipped - 5 lines]
> represented correctly in the .csv file. For example data like "Dékán"
> in the .xls sheet is represented like "Dékán" in the formatted file.

Maybe the CSV file is correct but you are not loading it or viewing it
with a UTF8 encoding? What does a hex dump of that file reveal?

> I wanted to know how to set the character set to UTF8 in the java
> class so that it represents the data correctly even after the
> formatting.

The API docs for the class will specify how to set the encoding.
e.g. new FileOutputStream("outfilename"), "UTF8");
Since you provide no code I can't identify the appropriate action for
your specific case.

> Any help would be appreciated.

If you read and act on http://sscce.org/ you will get help.

Signature

RGB

Andrew Thompson - 27 May 2008 13:21 GMT
...
> I wanted to know how to set the character set to UTF8 in the java
> class so that it represents the data correctly even after the
> formatting.

You might look to using an..
OutputStreamWriter(OutputStream, java.nio.charset.Charset)
..constructor with an appropriate Charset.

--
Andrew T.
PhySci.org
Sandy80 - 27 May 2008 13:39 GMT
The code that I use to populate the output file is:

out = new BufferedWriter(new FileWriter(surveyFilename));
Roedy Green - 27 May 2008 22:22 GMT
On Tue, 27 May 2008 03:32:12 -0700 (PDT), Sandy80
<svarshneymail@gmail.com> wrote, quoted or indirectly quoted someone
who said :

>The issue that I am facing is that some data in the .xls file is not
>represented correctly in the .csv file. For example data like "Dékán"
>in the .xls sheet is represented like "Dékán" in the formatted file.

you can identify the coding used with an Applet at
http://mindprod.com/jgloss/encoding.html

To read the data with various encodings, see
http://mindprod.com/applet/fileio.html
Signature


Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.