Uploaded image for project: 'Commons Configuration'
  1. Commons Configuration
  2. CONFIGURATION-538

Saving PropertiesConfiguration using UTF-8 encoding doesn't work

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 1.9
    • None
    • None
    • shouldn't be important, but 64bit Windows 7

    Description

      I created JUnit test http://goo.gl/GCwi2, that uses two methods to save PropertiesConfiguration (with property value containing utf-8 characters) into file:
      1) propsConf.save(file); // propsConf.setEncoding("UTF-8") was called before
      and
      2) propsConf.save(fileOutputStream, "UTF-8");

      Test shows that file doesn't contain UTF-8 characters. Instead saved file contains unicode escapes of non ISO-8859-1 characters.

      This seems wrong, as documentation on setEncoding() method says:
      "Set the encoding used to store the configuration file".
      PropertiesConfiguration.setEncoding() method currently seems to affect only loading the configuration.

      I added one test method that shows that even java.util.Properties class saves the same property value without any problems using utf-8 characters (not unicode escapes that it ) when using smth like that:
      props.store(new OutputStreamWriter(fos, "UTF-8"));

      It looks like a bug to me, or did i misunderstood smth?

      Attachments

        Activity

          People

            Unassigned Unassigned
            atsu85 Ats
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated: