Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Issue while reading French character from a text file  RSS feed

 
Suren Singh Khatana
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Guys ,

I wrote a piece of code to read a file which is having French chars in it and is saved as UTF-8 format and is a text file .




It reads french work like générale with out any issue but its unable to read word with capital French characters like Électrique

Any ideas !!


Thanks


 
Stephan van Hulst
Saloon Keeper
Posts: 6972
109
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How is it 'unable to read'? Are you getting errors? Unexpected values?
 
Suren Singh Khatana
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The character is malformed (some junk ) when read
 
Paul Clapham
Sheriff
Posts: 22185
38
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And how do you know that?

You must be displaying it in some way. In which case there are two steps:

(1) Read the data
(2) Display the data

You are assuming that the problem occurs in step (1). Why couldn't it be in step (2)?
 
Suren Singh Khatana
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am reading the data from the file and then just passing it to an third party API (some other app) which is displaying it on web page .

I don't have much info on how that app is writing , but its working fine for lower case characters,
so i just wanna understand if my reading is having issues with upper case french chars .

Thanks
 
Stephan van Hulst
Saloon Keeper
Posts: 6972
109
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's more likely that during display, the characters are either not interpreted correctly, or the typeface doesn't have glyphs for the characters.
 
Paul Clapham
Sheriff
Posts: 22185
38
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's right, if you want to test your application, then don't assume the other application is working correctly. Read one of the suspicious words into your code and see exactly what Unicode characters you get. Convert the suspicious characters to integers (just cast the chars to ints) and see if what you get there corresponds to what the Unicode code charts say you should get.
 
Stephan van Hulst
Saloon Keeper
Posts: 6972
109
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Or you could print them in a JTextArea or something using a font like MS Gothic.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!