participate


Sun Java Studio Enterprise - "unmappable character for encoding Cp1252" when building project
<<   Back to Forum  |   Give us Feedback Topics: « Previous | Next
This topic has 4 replies on 1 page.
flamenkito
Posts:3
Registered: 6/17/07
"unmappable character for encoding Cp1252" when building project   
Jun 17, 2007 12:17 AM

 
How can I tell Java Studio to build my project using UTF-8, so this warning message can go away?

Any help would be most appreciated.

Flamenkito
 
KarthikR
Posts:1,118
Registered: 10/27/97
Re: "unmappable character for encoding Cp1252" when building project   
Jun 17, 2007 11:30 AM (reply 1 of 4)  (In reply to original post )

 
1. A couple of related threads:
http://forum.java.sun.com/thread.jspa?forumID=17&threadID=534318
<div class="jive-quote">Setting the $LANG environment variable to "... resolves the problem and 
compiles my files as of before 1.5.0_02.</div>


http://forum.java.sun.com/thread.jspa?threadID=536562&messageID=2594883
<div class="jive-quote">You can compile your source code if you tell javac the character encoding of the 
source files. If you don't, javac assumes the system's default encoding. On Solaris, 
without any locale settings, the default encoding is ASCII which doesn't support the 
copyright symbol. The encoding can be specified with the "-encoding" switch. </div>


2. From within the ide, the help says encodiing can be specified via options window. But that sets only the encoding for the editor and not for compilation.

3. Based on the above, it looks like one way to solve the problem would be to specify the encoding for javac in the build script. But I am not sure how to perform this override. (I am not sure if you can directly modify build.xml etc because these may get regenerated by the ide...)

Can you try the following:
- The -init-macrodef-javac macro for javac is defined in build-impl.xml (nbproject/build.xml and other files are not visible in the project window. But you should be able to see them if you switch to the Files window of the navigator).
- Copy the macro and paste it in build.xml (this definition should override the one in build-impl.xml).
- Add "<attribute default="UTF-8"" name="encoding"/>
I haven't tried this myself though...

4. http://wiki.netbeans.org/wiki/view/FaqI18nFileEnc
 
flamenkito
Posts:3
Registered: 6/17/07
Re: "unmappable character for encoding Cp1252" when building project   
Jun 18, 2007 11:59 AM (reply 2 of 4)  (In reply to #1 )

 
You took me 99% of the way. Here's the solution:
 
1) Set the IDE to show java files in UTF-8:
      * click "Tools"
      * click "Options"
      * click "Advanded Options"
      * click "Java Sources"
      * click "..." next to "Default Encoding"
      * type in "utf-8" (without the quotes)
      * click "OK"
      * click "Close"
 
2) Edit the project's build.xml:
      * click the "Files" tab, in the project window
      * open nbproject/build-impl.xml
      * copy "<target name="-init-macrodef-junit">.....</target>"
      * open nbproject/build.xml
      * paste it underneath "<import file="nbproject/build-impl.xml"/>"
      * change <compilerarg line="${javac.compilerargs} />
        to <compilerarg line="${javac.compilerargs} -encoding utf-8"/>
      * save build.xml
 
Worked perfectly.
 
Cheers.
flamenkito
 
KarthikR
Posts:1,118
Registered: 10/27/97
Re: "unmappable character for encoding Cp1252" when building project   
Jun 18, 2007 12:15 PM (reply 3 of 4)  (In reply to #2 )

 
Glad it worked.

And thanks for posting the final solution!!
 
flamenkito
Posts:3
Registered: 6/17/07
Re: "unmappable character for encoding Cp1252" when building project   
Jun 20, 2007 3:21 PM (reply 4 of 4)  (In reply to #2 )

 
Just a small correction... in case someone tries this solution:
Instead of copying
    <target name="-init-macrodef-junit">.....</target>

I meant to write that you should copy
    <target name="-init-macrodef-javac">.....</target>

Thanks.
flamenkito
 
This topic has 4 replies on 1 page.
Back to Forum
 
Read the Developer Forums Code of Conduct

Click to email this message Email this Topic

Edit this Topic
  
 
 
Forums Statistics
    Users Online : 26
  • Guests : 122

About Sun forums
  • Sun Forums is a large collection of user generated discussions. It is here to help you ask questions, find answers, and participate in discussions.

    Check out our guide on Getting started with Sun Forums for a full walkthrough of how to best leverage the benefits of this community.

Powered by Jive Forums