Announcement Announcement Module
No announcement yet.
UTF-8 encoding for Resource Bundle Messages Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • UTF-8 encoding for Resource Bundle Messages

    I'm trying to output Cyrillic characters using Spring's i18n localization framework.

    I have set the encodingType of the VelocityView as follows:

    <property name="contentType" value="text/html; charset=UTF-8"/>
    The content type headers are set correctly. However, the encoding of the stream is incorrect. I'm guessing that this is because Resource Bundle properties files are read in as ISO 8859-1. Therefore I'm considering writing a new org.springframework.context.MessageSource implementation which uses Java 1.5 loadFromXML Properties methods (which allow the stream to be read as unicode).

    However, I find it odd that Spring's internationalisation is limited to Latin character sets, and therefore suspect I'm making a mistake.

    I would like to know if I can use Spring 1.2 to output cyrillic text in a resource bundle using the default infrastructure, and if so, what am I doing wrong?

  • #2
    If Spring solely relies on the underlying JDK functionality, then you're stuck with ISO-8859-1. Still, you can use any Unicode character in a resource bundle using standard Java Unicode escape sequences (\Uxxxx, where xxxx is the hexadecimal value of the character's Unicode code point).

    # Sample entry in a resource bundle&#58;
    jsp.sample.text=This will never end&#58; \u221e


    • #3

      Try PropEdit:

      It converts unicode to its ascii escape code.

      There's an eclipse plugin too.