How to generate java .properties files in python
Serhiy Storchaka
storchaka at gmail.com
Mon Dec 5 15:05:43 EST 2011
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 '!'.
And don't forget characters with code >0xFFFF.
More information about the Python-list
mailing list