Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 98880

Summary: "Text editor" and "Property editor" could display Chinese characters correctly
Product: [Eclipse Project] JDT Reporter: zhoutao <moonese>
Component: TextAssignee: JDT-Text-Inbox <jdt-text-inbox>
Status: CLOSED WORKSFORME QA Contact:
Severity: normal    
Priority: P3    
Version: 3.1   
Target Milestone: ---   
Hardware: PC   
OS: Windows 2000   
Whiteboard:
Attachments:
Description Flags
a sample property file that containing chinese characters
none
the display in my machine
none
Regional Options Setting in Control Panel
none
JAVA editor and Properties text font setting,
none
Text editor's font setting
none
the properties file in hex string none

Description zhoutao CLA 2005-06-08 01:28:34 EDT
I am running Eclipse 3.1 RC1, on windows 2000 English version,
when I open properties files containing chinese character, 
it could not display the correct text.
The property files is just simple text file, 
I also attached a sample file.

though I report in version 3.1 RC1, this problem is same in Eclise V3.0,

JDT's Java Editor doesn't have this problem.
Comment 1 zhoutao CLA 2005-06-08 01:31:34 EDT
Created attachment 22584 [details]
a sample property file that containing chinese characters

a sample property file that containing chinese characters
Comment 2 zhoutao CLA 2005-06-08 01:35:53 EDT
Created attachment 22585 [details]
the display in my machine

above is the original text, 
below is what it is displayed in property editor,
Comment 3 Dani Megert CLA 2005-06-08 01:51:36 EDT
You gave to install Chinese otherwise this won't work in Windows2000. On WinXP
you can simply add the additional input languages and fonts.
Comment 4 zhoutao CLA 2005-06-08 02:44:42 EDT
I do have installed chinese input language,
'cause in windows explorer, all chinese filenames could be displayed,
and also i have input chinese input languages,

just as i mentioned, JDT's Java Editor just could display chinese 
characters correctly in the same machine.
but neithor "Text Editor" nor "Property Editor" could work
Comment 5 zhoutao CLA 2005-06-08 02:59:54 EDT
Created attachment 22587 [details]
Regional Options Setting in Control Panel

Regional Options Setting in Control Panel
Comment 6 Dani Megert CLA 2005-06-08 03:34:50 EDT
Check whether they use the same font as the Java editor.
Comment 7 zhoutao CLA 2005-06-08 03:53:59 EDT
Created attachment 22590 [details]
JAVA editor and Properties text font setting, 

JAVA editor and Properties text font setting, which is same to text editor's
font setting
Comment 8 zhoutao CLA 2005-06-08 03:59:10 EDT
Created attachment 22591 [details]
Text editor's font setting

Text editor's font setting, which is GBK,
if text editor does use this setting - *GBK*, 
it will be OK to display Chinese character.

I also changed to UTF-8, UTF-16, etc, but also could not work
Comment 9 Dani Megert CLA 2005-06-08 04:07:41 EDT
OK, I now see what happens. It's about the *encoding* not the font. If you
create new properties, Java or text files they get the content types default
encoding:

*.properties files: ISO-8859-1
*.java: non / platform default

so, it's not about the editor but about what encoding is used. Try this: create
a file in the Java editor which looks good, save and open with either the Text
or Properties edtior.
Comment 10 zhoutao CLA 2005-06-08 04:19:40 EDT
Created attachment 22592 [details]
the properties file in hex string

another thing i just noticed is:
the file containing Chinese Characters in the properties file which I created
outside Eclipse could not display correctly,
but when I input Chinese characters in the *Property Editor*,
Chinese Character could be inputed also displayed OK, without any problem, 
but when I close the file in Eclipse, and open again, 
the place which would be chinese characters were replaced by two "??",

the attached is the hex string of the file after I saved.

So, it seems that when the file is saved,
some encoding conversion has been done to it, but failed to convert to the
corrent encode.

I just quite puzzled why in Java Editor, no this problem.
I can input Chinese Characters, save, open, all fine.
Comment 11 zhoutao CLA 2005-06-08 04:26:32 EDT
Hi, Daniel Megert:

I just input some chinese characters inside the .java file, 
close it, then open with text editor, 
OK, no problem, the characters I input could be displayed OK.
vice verse, I create a new text in the Eclipse environment,
by New-> Simple -> Untitled Text File,
input some Chinese Characters, save to disk, close, open, 
also OK, no problem.

But if the file was created outside Eclipse beforehand,
It will failed by the same operation.

you right, its an encoding problem,
Comment 12 Dani Megert CLA 2005-06-08 04:43:00 EDT
The problem is that if the encoding can't be determined from the file the
default is used: select the file in the Navigator or Package Exlporer and see
what encoding is used. *.properties files have ISO-8859-1 encoding per default
and hence you can't type in special chars. You can change this by changing the
default encoding for the properties file content type but that's not recommended
since Java properties files are speced to have ISO-8859-1 encoding.

Note that you can also set the default encoding on folders and files but that
changing the encodign *does not* convert existing files.
Comment 13 zhoutao CLA 2005-06-08 05:00:20 EDT
OK. i see.