Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #16683 > unrolled thread

Re: How to generate java .properties files in python

Started bySerhiy Storchaka <storchaka@gmail.com>
First post2011-12-05 22:05 +0200
Last post2011-12-05 22:05 +0200
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: How to generate java .properties files in python Serhiy Storchaka <storchaka@gmail.com> - 2011-12-05 22:05 +0200

#16683 — Re: How to generate java .properties files in python

FromSerhiy Storchaka <storchaka@gmail.com>
Date2011-12-05 22:05 +0200
SubjectRe: How to generate java .properties files in python
Message-ID<mailman.3318.1323115809.27778.python-list@python.org>
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.

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web