This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 98874 - I18N - Templates encoding problems
Summary: I18N - Templates encoding problems
Alias: None
Product: java
Classification: Unclassified
Component: Unsupported (show other bugs)
Version: 6.x
Hardware: All All
: P3 blocker (vote)
Assignee: Jan Pokorsky
Keywords: I18N
Depends on:
Blocks: 95399
  Show dependency tree
Reported: 2007-03-24 11:56 UTC by tprochazka
Modified: 2007-09-26 09:14 UTC (History)
6 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Note You need to log in before you can comment on or make changes to this bug.
Description tprochazka 2007-03-24 11:56:21 UTC
Tested in NB 6 build 200703221900

Steps to reproduce:

Create project with UTF-8 encoding.
Open Java Class template and put ěščřžýáí chars to it.
Create new class file.
ěščřžýáíé is OK
but __DATE__ is 23. b�ezen 2007 ( I'm using cz_cs locale)
Template variables uses different than templates.

Switch project to Windows-1250
Create new class
ěščřžýáíé is created as: ěščřžýáé
but __DATE is corectly displayed as 23. březen 2007

I think:

Templates variables use native encoding (windows 1250 on Windows)
Templates itself use UTF-8 encoding
When NB project use different encoding from templates, templates doesn't 

I don't understand it. Why NB doesn't use for all internall operation unicode? 
Only when user load or save .java file, NB take conversion from/to unicode.
Comment 1 Jesse Glick 2007-03-24 15:52:24 UTC
Sorry, what does this have to do with apisupport?
Comment 2 tprochazka 2007-03-24 19:59:45 UTC
Sorry. I was not idea where this is. I searched for "template" in this page
Comment 3 Jaroslav Tulach 2007-03-25 13:46:58 UTC
What the issue has to do with me? Primarily this is bug in the Java templates, 
I am not saying something is not wrong openide/loaders, however I need Java 
guys to help me understand what it is.
Comment 4 Tomas Zezula 2007-03-26 09:31:10 UTC
Related to #94676
Comment 5 Jan Pokorsky 2007-03-26 10:52:37 UTC
It relates to old templates see e.g. __DATE__. Jarda fixed encoding of new
tempates in,v 1.3

To Jarda and Tomas: should not the template support register
FileEncodingQueryImplementation to provide UTF-8 as default encoding for files
located on SFS? Templates are not part of any project so UTF-8 seems to be
reasonable. Nowadays default impl in DataObjectEncodingQueryImplementation
returns null that is resolved as Charset.defaultCharset() by FileEncodingQuery.
Comment 6 Tomas Zezula 2007-03-26 12:28:15 UTC
To Honza: Update sources, Jarda already implemented this previous week. :-)
Comment 7 Jan Pokorsky 2007-03-26 12:53:57 UTC
I have fresh sources. Jarda added FileEncodingQuery to,v 1.3 as I mentioned before. That's OK.
But this query returns Charset.defaultCharset() for templates. Could you point
me to FileEncodingQueryImplementation instance that returns UTF-8 for templates
Comment 8 Tomas Zezula 2007-03-26 14:03:04 UTC (77)
Comment 9 Jan Pokorsky 2007-03-27 16:18:35 UTC
Thanks for the pointer. So after integrating of issue #95399 I consider this as
fixed for J2SE templates then.
Comment 10 Tomas Zezula 2007-03-27 17:28:23 UTC
Doesn't seem to work correctly on Japanese Solaris.
Comment 11 Jan Pokorsky 2007-03-27 17:45:48 UTC
Please be more specific. What exactly does not work? What template, build, ...? 
Comment 12 Tomas Zezula 2007-03-27 18:13:52 UTC
Current trunk, new Java file when local is jp-EUC and project encoding is UTF-8.
Comment 13 Tomas Zezula 2007-03-28 09:03:15 UTC
Partial fix, correct encoding is used also for old templates. Don't work for
templates with guarded blocks (forms).

Checking in src/org/netbeans/modules/java/;
/cvs/java/source/src/org/netbeans/modules/java/,v  <--
new revision: 1.3; previous revision: 1.2
Checking in src/org/netbeans/modules/java/;
/cvs/java/source/src/org/netbeans/modules/java/,v  <--
new revision: 1.3; previous revision: 1.2
Comment 14 Jan Pokorsky 2007-03-28 12:27:35 UTC
Not only old form module's templates with guarded blocks but form files should
also work now. The form module was not adapted to FileEncodingQuery.

/cvs/form/src/org/netbeans/modules/form/,v  <--
new revision: 1.206; previous revision: 1.205
Checking in ide/golden/deps.txt;
/cvs/ide/golden/deps.txt,v  <--  deps.txt
new revision: 1.492; previous revision: 1.491
Checking in form/nbproject/project.xml;
/cvs/form/nbproject/project.xml,v  <--  project.xml
new revision: 1.39; previous revision: 1.38
Comment 15 Tomas Zezula 2007-03-28 12:49:46 UTC
The fix of FormEditorSupport is not correct event it will probably work for form
files. The problem is that the GuardedSectionsProvider is an public SPI and
correct .implementation for JSP or XML  may be impossible.
Comment 16 Tomas Zezula 2007-03-29 10:20:51 UTC
OK, the API problems with guarded reader does not affect any existing code. So
Honza will solve it in separate issue. Closing as fixed, both old and new java
templates, including forms, work fine.
Comment 17 tprochazka 2007-04-03 16:54:19 UTC
I confirm it. Encoding problems are gone.

But it's interesting, that template for Class file use differen format now and 
when I have my own template with old style, it doesn't work. But for example 
JPanel or Jform template use also old style templates and works.
Comment 18 Ken Frank 2007-05-25 20:08:51 UTC
based on tprochazka comments, will mark as verified.