Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Cannot Display UTF-8 Encoded Files ?  RSS feed

 
AhFai Chan
Ranch Hand
Posts: 81
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I need to read and write UTF-8 encoded files, they are in Simplified Chinese
The original Chinese file was created on a Windows10 platform using WordPad
I am running eclipse on Windows7

Both Firefox and MS Word display the original file in Chinese characters correctly.

But I cannot get eclipse to display the characters, nor write to an .rtf (rich text format) file.

At a guess, it is not in UTF-8 format, something about "fcharset134 SimSun" ?!?

Can anyone see what I did wrong???

Here is what eclipse displays:

1 {\rtf1\ansi\ansicpg1252\deff0\nouicompat\deflang1033\deflangfe2052{\fonttbl{\f0\fnil\fprq2\fcharset134 SimSun;}}
2 {\*\generator Riched20 6.3.9600}{\*\mmathPr\mnaryLim0\mdispDef1\mwrapIndent1440 }\viewkind4\uc1
3 \pard\nowidctlpar\sa200\sl276\slmult1\b\f0\fs40\lang2052\'ce\'d2\'cf\'eb\'c2\'f2\'d7\'d4\'d0\'d0\'b3\'b5\par
4 \'b5\'d8\'cc\'fa\par
5 \'b8\'df\'cc\'fa\par
6 \'b9\'ab\'b9\'b2\'c6\'fb\'b3\'b5\'d5\'be\'d4\'da\'c4\'c7\'a3\'bf\par
7 \'bc\'fb\'bc\'d2\'c8\'cb\par
8 \par
etc etc

This is the code...

 
Stefan Evans
Bartender
Posts: 1837
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
UTF-8 encoded Text files should be fine with the example code you have shown.

Unfortunately, rtf is more than just a UTF-8 encoded text file.
You will need more than the standard java API to deal with rtf.
 
AhFai Chan
Ranch Hand
Posts: 81
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Stefan Evans wrote:UTF-8 encoded Text files should be fine with the example code you have shown.

Unfortunately, rtf is more than just a UTF-8 encoded text file.
You will need more than the standard java API to deal with rtf.


Googled it.

Yes, you are right.

Thanks.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!