Skip to content Skip to sidebar Skip to footer

How To Use Latin Letters In Eclipse?

I have some text in my ProgressDialog, and some other places and after I save it and run it on my phone it works fine. But as soon as I restart Eclipse I get the situation like on

Solution 1:

Right click on your project and select Properties. Click on Resource, and change the Text file encoding to UTF-8 or something else that will support the characters you want to use.

To change the default encoding setting for .java files (or other file types), go to Window > Preferences > Content Types. Under Text, select Java Source File. Set the Default Encoding to what you want.

Solution 2:

You should check that the encoding for your project is Unicode.

Also, if you work on a source-controlled environment, you should check that other committers also use Unicode.

For instance in Eclipse:

Preferences
General
Workspace
Text file encoding

... or for this project only...

Project
Resource
Text file encoding

Solution 3:

when eclipse notifys you to save the file as UTF-8 , save it as UTF-8 and the better way is to put the message in strings.xml file instead of putting it the code directly.

Solution 4:

While Mena's/Garrett's answers are likely all you need to get it to display what you want I'd like to point out that best practice would be to externalise the String you're hard-coding there. If you externalise it, depending on your choice of method, you can then specify encoding on that file if and when needed instead of worrying about the character set for the code itself (which in itself can be an advantage in that other devs won't have to worry about changing character sets etc.).

It's also perhaps worth noting that it being displayed incorrectly in Eclipse by no means means the String will display incorrectly elsewhere - the bytes are unchanged, you just need to know the character set when reading in order to display it correctly, so if it worked fine on your phone, it will even after modifying and re-compiling the file (at least in most cases).

Solution 5:

Try replacing the literal characters with the unicode value - '\uxxxxx'

Post a Comment for "How To Use Latin Letters In Eclipse?"