commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Oliver Heger (JIRA)" <>
Subject [jira] [Commented] (CONFIGURATION-538) Saving PropertiesConfiguration using UTF-8 encoding doesn't work
Date Mon, 08 Apr 2013 20:19:16 GMT


Oliver Heger commented on CONFIGURATION-538:

In its {{escapeValue()}} method {{PropertiesConfiguration.PropertiesWriter}} performs an escaping
of a configuration property before it gets written to file. The method used to call {{StringEscapeUtils.escapeJava()}}
from Commons Lang. For CONFIGURATION-516 this was changed to use a custom CharSequenceTranslator
which is derived from the one used by {{StringEscapeUtils}}, but has restricted encoding rules.
(This is the current state in subversion.)

Obviously, it still performs too much encoding, it especially incorporates a {{UnicodeEscaper.outsideOf(32,
0x7f)}} rule. It should be possible to tweak the configuration of the CharSequenceTranslator
used for this encoding, but I don't know which rules are actually necessary. Could this {{UnicodeEscaper}}
declaration be skipped completely?
> Saving PropertiesConfiguration using UTF-8 encoding doesn't work
> ----------------------------------------------------------------
>                 Key: CONFIGURATION-538
>                 URL:
>             Project: Commons Configuration
>          Issue Type: Bug
>    Affects Versions: 1.9
>         Environment: shouldn't be important, but 64bit Windows 7
>            Reporter: Ats
>              Labels: PropertiesConfiguration,, charset, encoding,, save
> I created JUnit test, that uses two methods to save PropertiesConfiguration
(with property value containing utf-8 characters) into file:
> 1); // propsConf.setEncoding("UTF-8") was called before
> and
> 2), "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
> 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:
> OutputStreamWriter(fos, "UTF-8"));
> It looks like a bug to me, or did i misunderstood smth?

This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see:

View raw message