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)
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
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
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
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
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
>>
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
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