3

I have used localisation for my application in Chinese and English. It is a Spring MVC application and I am getting the values from a properties file. I have encoded the JSP pages in UTF-8 and mentioned UTF-8 encoding in web.xml also.

If I hardcode a Chinese character in the JSP page, it is displayed correctly, but the characters coming from the properties file are garbled and displayed like ç§ç®åç§°.

When I am doing wrong ?

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
Pratik
  • 2,532
  • 2
  • 21
  • 29

1 Answers1

3

The problem is that the Java properties files are/must/should been encoded in ´ISO-8859-1´ (Latin-1) by default. Thats an Java requirement.

To overcome this you can go two ways:

  • escape the not Latin-1 characters by UTF-8 sequences in the property file: back=Zur\u00EF\u00BF\u00BDck (german word ("Zurück") with some none Latin-1 charachters)

  • or you encode the properties files in UTF-8 and manipulate the way how Spring load the properties files.

I would go the first way (it is more standard) - Then I would recommend to use a tool like ResourceBundle Editor (it does the encoding stuff)

@See also this question and its answers:

not_Prince
  • 320
  • 3
  • 17
Ralph
  • 118,862
  • 56
  • 287
  • 383