Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #16685
| References | <CAJ6cK1aLyX0QSA3K3b+Rc+BPi9xZvbYJaEFk3-ijhdQWcdi9_w@mail.gmail.com> <jbj86t$r9e$1@dough.gmane.org> |
|---|---|
| Date | 2011-12-05 20:25 +0000 |
| Subject | Re: How to generate java .properties files in python |
| From | Arnaud Delobelle <arnodel@gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.3320.1323116742.27778.python-list@python.org> (permalink) |
On 5 December 2011 20:05, Serhiy Storchaka <storchaka@gmail.com> wrote:
> 03.12.11 23:34, Arnaud Delobelle написав(ла):
>
>> Is there a simple way to achieve this? I could do something like this:
>>
>> def encode(u):
>> """encode a unicode string in .properties format"""
>> return u"".join(u"\\u%04x" % ord(c) if ord(c)> 0xFF else c for c
>> in u).encode("latin_1")
>
>
> You must also encode backslash ('\\'), whitespaces and control characters
> (ord(c)<=32), '=' and ':' (key/value delimiters), '#' (comment) and '!'.
Fortunately there aren't any of these in the keys.
> And don't forget characters with code >0xFFFF.
I haven't thought of these. I don't think that I have any, but I'll
check. Do you know how they are encoded?
--
Arnaud
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: How to generate java .properties files in python Arnaud Delobelle <arnodel@gmail.com> - 2011-12-05 20:25 +0000
csiph-web