Source file encoding in NetBeans IDE
- 42638 : I18N - Provide support for File Encoding

See the screenshot above, encoding of only Java source file can be controlled in current NetBeans on option dialog. The setting can be changed in entire IDE and per individual file, but it's not realistic. We usually don't use different encoding in individual file in one project. So I think the setting should be stored as project property. It also can help when we use version control system e.g. CVS. After checking out NetBeans projects from CVS, we will be able to get file encoding from project property.
Did you have any trouble about file encoding when you use NetBeans? If so, please join the discussion of Issue 42638.




Posted by Claudio Miranda on August 25, 2006 at 12:17 AM JST #
Posted by Masaki on August 25, 2006 at 06:37 PM JST #
Posted by Tomas Prochazka on September 11, 2006 at 10:58 PM JST #
Posted by Masaki on September 11, 2006 at 11:09 PM JST #
Posted by Gene Kouras on November 01, 2006 at 11:11 AM JST #
Posted by Masaki on November 01, 2006 at 05:48 PM JST #
Posted by LiuYan on November 22, 2006 at 04:03 PM JST #
Posted by vigor on January 09, 2007 at 08:01 PM JST #
Posted by bact' on January 28, 2007 at 08:23 PM JST #
i am running mac osx in japanese. should netbeans pick this up as default encoding for the system?
it has problems reading simple UTF-8 template files, coming out as mojibake (with or without BOM).
is there any workaround for this? i dont mind if all files are treated as utf8.
this is a shame, as this was the main reason to switch away from textmate - finally to be able to enter japanese text.
残念ですね。
Posted by dc on September 25, 2007 at 12:59 AM JST #
Thank you very much for comment, dc. Do you use .java files? or some other files? Have you tried NetBeans 6.0? It's can handle UTF-8 encoding by default. You can customize the encoding on Project Properties.
Posted by masaki on September 25, 2007 at 12:02 PM JST #
I've recently got similar problem.
I'm trying to use russian language in .properties file in Netbeans 5.5.1 under Ubuntu Linux. UTF-8 is the default encoding, but still I've got garbage instead of my messages.
However, HTML files with russian language edited in NetBeans look okay.
I've tried to edit and save that .properties file with Gedit, and the behavior is a little bit different. Now instead of just question marks (?????) which I saw when the .properties file was edited in NetBeans, I've got complete garbage (Инд) where it supposed to be "Индекс".
Posted by sp on September 25, 2007 at 07:07 PM JST #
Hi sp, thanks for comments. Hmm, I understand that NetBeans opens .properties files as unicode ascii, not the native encoding. So when you open the .properties files, it should be like \u...\u... instead of native characters. NetBeans does not use native characters in Editor. How about using "Open" action to edit the .properties files? It should be OK, properties editor will be invoked. See the screeshot in http://blogs.sun.com/katakai/resource/nb_rb_2.jpg. You can see the native characters on that Editor.
Posted by masaki on September 25, 2007 at 07:38 PM JST #
Btw, please note this encoding setting is just for .java file, not for .properties file. This behavior is the same even on NetBeans 6.0. .properties files are always being stored as unicode ascii.
Posted by masaki on September 25, 2007 at 07:42 PM JST #
masaki, thanks a lot, that did it.
I've opened the file with the context menu's "open", entered russian values and it displays okay :).
Posted by sp on September 25, 2007 at 07:52 PM JST #
It's great!
There is one enhancement at 6.0. When you use NetBeans 6.0, even "Edit" menu can open the contents of .properties properly, not unicode ascii. So you can edit .properties file directly. But please note that once it's saved, .properties file is stored as unicode ascii.
Posted by masaki on September 25, 2007 at 08:07 PM JST #
I am trying problems with Russian character (cyrillic) also. I am able to copy and paste into the properties file just fine. But when I save it and open it again, all I see are ???? where the cyrillic character were. Do you know how I can save a properties with the cyrillic and have java bring them back up when I specify the appropriate user.language and user.country?
Thanks,
Scott
Posted by scott on September 29, 2007 at 12:20 AM JST #
2 scott:
You have to edit the .properties file in the "properties editor" like on the screenshot, not as a plain text file.
To open the editor you have to right-click on the .properties file in the "Projects" and select "open" in the context menu.
Posted by sp on September 29, 2007 at 12:26 AM JST #
sp THANK YOU SOOOOOOOOOOO MUCH!!!!!!!!!
Scott
Posted by scott on September 29, 2007 at 12:32 AM JST #
Hi! I want to develop existed project in NetBeans. All files are utf-8 encoded in it. I've set project encoding in project properties and now I can see *.java files well, but in *.js files russian text looks like "Подождите". As I understand NetBeans uses my default encoding (win-1251) to show *.js files in editor. How to avoid this behaviour?
Product Version: NetBeans IDE 6.1 (Build 200805300101)
Java: 1.5.0_14; Java HotSpot(TM) Client VM 1.5.0_14-b03
System: Windows XP version 5.1 running on x86; Cp1251; ru_RU (nb)
Posted by dealer on July 11, 2008 at 10:05 PM JST #
Hi Dealer, Thanks for comment. Some of files seem to use the default encoding of your system. To avoid it, could you try to use "-J-Dfile.encoding=UTF-8" option to NetBeans. Please see the reference : http://wiki.netbeans.org/FaqI18nFileEnc
Posted by Masaki on July 11, 2008 at 10:30 PM JST #
Thanks, Masaki! It seems that -J-Dfile.encoding=UTF-8 works for me )
Posted by dealer on July 14, 2008 at 03:18 PM JST #