1

I have an application which uses swedish language in some java and jsp pages.
Swedish words are described in application.properties file and those names will be used in the application.

Application Screen:

Application Screen**strong text**

Words which are defined in the properties file and the words which I am seeing in the jsp page is different.

button.search=Sök 

I tried all content types in the settings. Still I am getting this error and because of this different words my application is not working in eclipse.

Could you please anyone tell me what changes I need to do in eclipse to make this application work

4 Answers 4

2

From your screenshot it looks like your properties file is encoded in UTF-8, thus ö is represented by 2 bytes.

But properties files must be encoded in ISO-8859-1 (optionally with \uXXXX escapes), not in UTF-8 or anything else.

Quoted from the javadoc of class java.util.Properties:

The load(Reader) / store(Writer, String) methods load and store properties from and to a character based stream in a simple line-oriented format specified below. The load(InputStream) / store(OutputStream, String) methods work the same way as the load(Reader)/store(Writer, String) pair, except the input/output stream is encoded in ISO 8859-1 character encoding. Characters that cannot be directly represented in this encoding can be written using Unicode escapes [...]

That means, you should store your application.properties file in ISO-8859-1 encoding. Or better yet, you should write

button.search=S\u00F6k 

instead of

button.search=Sök 

Using the \uXXXX escapes for all non-ASCII characters has the advantage that you can store the file in UTF-8 or any ISO-8859-x, and you get the same file content anyway.

Sign up to request clarification or add additional context in comments.

2 Comments

I have used ISO 8859-1 enconding for the Application.properties file and in the jsp and it is working fine. Now there is one more issue here. JSP will get the value from Application.properties file and the same value will be used in Action class. if I check the value in the action class I am getting the same issue as mentioned earlier
in short I am getting the issue while fetching the value from Application. properties in .java file.
2

Just use Eclipse's Properties Editor. It saves a .properties file in the only allowed character encoding (ISO 8859-1) and \u escapes characters that are not in that character set.

It does have a hover display to show decoded codepoints but a view showing a table of name-value pairs would be nicer.

enter image description here

Comments

0

Maybe change the workspace encoding will help. Go Window -> Preferences -> General -> Workspace and change the text file encoding to UTF8.

Comments

-1

Change you eclipse default content type:

Window > Preferences > General > Content Types, set UTF-8 as the default encoding for all content types.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.