Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy do I need to escape unicode in java source files?
    primarykey
    data
    text
    <p>Please note that I'm not asking how but why. And I don't know if it's a RCP specific problem or if it's something inherent to java.</p> <p>My java source files are encoded in UTF-8.</p> <p>If I define my literal strings like this :</p> <pre><code> new Language("fr", "Français"), new Language("zh", "中文") </code></pre> <p>It works as I expect when I use the string in the application by launching it from Eclipse as an Eclipse application :</p> <p><img src="https://i.stack.imgur.com/5iMfZ.png" alt="enter image description here"></p> <p>But if fails when I launch the .exe built by the "Eclipse Product Export Wizard" :</p> <p><img src="https://i.stack.imgur.com/anwJs.png" alt="enter image description here"></p> <p>The solution I use is to escape the chars like this :</p> <pre><code> new Language("fr", "Fran\u00e7ais"), // Français new Language("zh", "\u4e2d\u6587") // 中文 </code></pre> <p>There is no problem in doing this (all my other strings are in properties files, only the languages names are hardcoded) but I'd like to understand.</p> <p>I thought the compiler had to convert the java literal strings when building <a href="http://en.wikipedia.org/wiki/Java_class_file#The_constant_pool" rel="nofollow noreferrer">the bytecode</a>. So why is the unicode escaping necessary ? Is it wrong to use use high range unicode chars in java source files ? What happens exactly to those chars at compilation and in what it is different from the handling of escaped chars ? Is the problem just related to RCP cache ?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload