Java Editor and Unicode Characters

I'm trying to use unicode characters in strings with the Java Editor.

String myOption = "\u2666 " + myDirName;

This works nicely, displaying a diamond in my web application. Source HTML contains a &9830;

However, if I make changes in the Visual Designer (e.g., add a button), the \u2666 in my Java code changes to a diamond symbol. When that happens, I get a "?" in my web application.

How do I prevent Java Editor from switching to the display character?

[488 byte] By [dsv] at [2007-11-26 8:55:52]
# 1
I believe the problem is that the vehicle your web application is using to display the character (browser?) is not using a characterset that can display the character, instead substituting the "?". Try specifying a characterset that includes that character.
ChuckBing at 2007-7-6 22:54:06 > top of Java-index,Development Tools,Java Tools...
# 2

Thanks for your response.

After more research, I found that the .java file is corrupted. These means the problem is not related to the browser.

When I have "\u2666" in the Java Editor window, I see "\u2666" in the .java file in Word Pad. This is properly compiled and the entity ♦ appears in the HTML.

When the diamond symbol is in the Java Editor window, I see and ascii ? (character #3F). I get a ? in the browser. It is really a question mark (#3F) not an unknown character.

So, it appears that when the JSP is changed by adding a button, the .java code is rewritten to disk but unicode characters are not translated properly. Or - something like that. If I could keep the ascii string "\u2666" from converting to the diamond, I would be all set.

I can edit the Java Code, close, save and reopen all I want and the unicode character doesn't translate to the symbol. This ONLY happens when the JSP is modified.

Any ideas?

dsv at 2007-7-6 22:54:06 > top of Java-index,Development Tools,Java Tools...
# 3

As I said, the "?" character is being substituted for the "black diamond" character somewhere in the process you're using. If you're saving the data to a file, you need to specify an encoding when you save the file that includes a character for the value 2666h, otherwise the "?" will be substituted. If you're not saving the data as a file, the program that's displaying the character needs to know what characterset to use to display the character, otherwise it will do the same. Try UTF-16 encoding.

ChuckBing at 2007-7-6 22:54:06 > top of Java-index,Development Tools,Java Tools...