You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Денис Матвеев <ma...@gmail.com> on 2017/10/31 11:52:50 UTC

unicode string in file

Hello, anybody can help?

I have such file properties

File file = new File("aaa.cfg");
Parameters params = new Parameters();
FileBasedConfigurationBuilder<PropertiesConfiguration> builder =
                 new 
FileBasedConfigurationBuilder<>(PropertiesConfiguration.class);
         builder.configure(params.properties()
                 .setFile(file)
                 .setEncoding("UTF-8")
                 .setListDelimiterHandler(new 
DefaultListDelimiterHandler(';')));
PropertiesConfiguration defProps = builder.getConfiguration();
props.setProperty("propname", "national encoding string");
builder.save();

How do I get Props not to save a string in file like this
propname = \u0442\u0435\u0441\u0442\u043E\u0432\u0430\

Comments saves well readable.

Thanks

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Re: unicode string in file

Posted by Gary Gregory <ga...@gmail.com>.
Hi,

In Java < 9, dot properties files are  ISO 8859-1. In Java 9, you can use
UTF-8, please see
https://docs.oracle.com/javase/9/intl/internationalization-enhancements-jdk-9.htm#JSINT-GUID-AF5AECA7-07C1-4E7D-BC10-BC7E73DC6C7F

Gary

On Tue, Oct 31, 2017 at 5:52 AM, Денис Матвеев <ma...@gmail.com> wrote:

> Hello, anybody can help?
>
> I have such file properties
>
> File file = new File("aaa.cfg");
> Parameters params = new Parameters();
> FileBasedConfigurationBuilder<PropertiesConfiguration> builder =
>                 new FileBasedConfigurationBuilder<
> >(PropertiesConfiguration.class);
>         builder.configure(params.properties()
>                 .setFile(file)
>                 .setEncoding("UTF-8")
>                 .setListDelimiterHandler(new DefaultListDelimiterHandler(';
> ')));
> PropertiesConfiguration defProps = builder.getConfiguration();
> props.setProperty("propname", "national encoding string");
> builder.save();
>
> How do I get Props not to save a string in file like this
> propname = \u0442\u0435\u0441\u0442\u043E\u0432\u0430\
>
> Comments saves well readable.
>
> Thanks
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> For additional commands, e-mail: user-help@commons.apache.org
>
>