LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices



Reply
 
Search this Thread
Old 02-19-2011, 03:16 PM   #1
Whatif
Member
 
Registered: Nov 2010
Distribution: VectorLinux
Posts: 87

Rep: Reputation: 0
Displaying Unicode Characters


I wrote a java program that writes strings to a file. The strings contain foreign language characters. When I run the program in Windows, the output file shows the foreign characters. However, when I attempt the same operation in Linux, the output file shows a white question mark in a black background instead of the foreign characters.

The same Linux system could display the foreign characters if I copy the output file from Windows to Linux. I tried to create the output file using gedit that my program would then add additional strings to and chose Unicode-32 for encoding but still the same problem.

What could I do to get the program to display the foreign language characters from output text file?

Your help will be much appreciated,
Mike
 
Old 02-19-2011, 05:17 PM   #2
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,004
Blog Entries: 11

Rep: Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903
What's your locale?
 
Old 02-19-2011, 09:43 PM   #3
Whatif
Member
 
Registered: Nov 2010
Distribution: VectorLinux
Posts: 87

Original Poster
Rep: Reputation: 0
LANG=en_US.UTF-8
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL
 
Old 02-20-2011, 12:44 AM   #4
graemef
Senior Member
 
Registered: Nov 2005
Location: Hanoi
Distribution: Fedora 13, Ubuntu 10.04
Posts: 2,379

Rep: Reputation: 148Reputation: 148
It could be that the font you are using in your program doesn't have the characters to display some of your unicode characters. Whilst the font used in gedit does.
 
Old 02-20-2011, 09:19 AM   #5
Whatif
Member
 
Registered: Nov 2010
Distribution: VectorLinux
Posts: 87

Original Poster
Rep: Reputation: 0
I don't use the program to display the characters. At the end when the program done writing to the text file, I open the text file to check the result. The text file opens in gedit. gedit could display foreign characters from the file generated on Windows but can't do the same for the file generated on Linux by the same program.
 
Old 02-21-2011, 05:08 PM   #6
Whatif
Member
 
Registered: Nov 2010
Distribution: VectorLinux
Posts: 87

Original Poster
Rep: Reputation: 0
I checked the difference between the two files generated by the program on Windows and Linux. I found that the file from Windows has Western (ISO-8859-15) encoding. I then changed the encoding of the file on Linux hoping that it would fix the problem. The white question mark in a black background is no longer present but there are weird characters instead of the foreign characters. When I opened both files in Linux using gedit both of them used the same font, Monospace.

Any suggestions as to what I should do next?
 
Old 02-21-2011, 06:42 PM   #7
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,004
Blog Entries: 11

Rep: Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903
What does
Code:
file -bi
think the encoding of the java generated file in Linux is?

I'm wondering whether java somehow ignores the OSes LC and
goes w/ something else instead.



Cheers,
Tink
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Printing Unicode characters in C Completely Clueless Programming 3 09-05-2009 05:13 PM
how do new unicode characters get implemented j1wu Linux - Software 1 04-18-2009 02:23 AM
unicode/japanese characters in C merc64 Programming 6 03-13-2007 08:00 PM
cyrillic, unicode fonts not displaying under FC5 peter88 Linux - General 5 12-06-2006 03:08 AM
Unicode characters in Firefox Ephracis Linux - Software 6 10-14-2005 05:05 PM


All times are GMT -5. The time now is 09:23 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration