Re: How to generate java .properties files in python

2011-12-05 Thread Arnaud Delobelle
On 5 December 2011 21:46, Serhiy Storchaka wrote: > 05.12.11 22:25, Arnaud Delobelle написав(ла): >> On 5 December 2011 20:05, Serhiy Storchaka  wrote: >>> You must also encode backslash ('\\'), whitespaces and control characters >>> (ord(c)<=32), '=' and ':' (key/value delimiters), '#' (comment)

Re: How to generate java .properties files in python

2011-12-05 Thread Serhiy Storchaka
05.12.11 22:25, Arnaud Delobelle написав(ла): > On 5 December 2011 20:05, Serhiy Storchaka wrote: >> 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

Re: How to generate java .properties files in python

2011-12-05 Thread Arnaud Delobelle
On 5 December 2011 20:05, Serhiy Storchaka 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) i

Re: How to generate java .properties files in python

2011-12-05 Thread Serhiy Storchaka
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 a

Re: How to generate java .properties files in python

2011-12-04 Thread Arnaud Delobelle
On 4 December 2011 10:22, Peter Otten <__pete...@web.de> wrote: > I found another one: > u"äöü ΦΧΨ".encode("latin1", "backslashreplace") > '\xe4\xf6\xfc \\u03a6\\u03a7\\u03a8' That's it! I was hoping for a built-in solution and this is it. FTR, the 'backslashreplace' argument tells the enco

Re: How to generate java .properties files in python

2011-12-04 Thread Peter Otten
Arnaud Delobelle wrote: > On 3 December 2011 23:51, Peter Otten <__pete...@web.de> wrote: >> Arnaud Delobelle wrote: >> >>> I need to generate some java .properties files in Python (2.6 / 2.7). >>> It's a simple format to store key/value pairs e.g. >>> >>> blue=bleu >>> green=vert >>> red=rouge >>

Re: How to generate java .properties files in python

2011-12-04 Thread Arnaud Delobelle
On 3 December 2011 23:51, Peter Otten <__pete...@web.de> wrote: > Arnaud Delobelle wrote: > >> I need to generate some java .properties files in Python (2.6 / 2.7). >> It's a simple format to store key/value pairs e.g. >> >> blue=bleu >> green=vert >> red=rouge >> >> The key/value are unicode strin

Re: How to generate java .properties files in python

2011-12-03 Thread Peter Otten
Arnaud Delobelle wrote: > I need to generate some java .properties files in Python (2.6 / 2.7). > It's a simple format to store key/value pairs e.g. > > blue=bleu > green=vert > red=rouge > > The key/value are unicode strings. The annoying thing is that the > file is encoded in ISO 8859-1, with