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


Groups > comp.lang.python > #16685

Re: How to generate java .properties files in python

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <arnodel@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.003
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'check.': 0.07; 'backslash': 0.09; 'subject:files': 0.09; 'subject:java': 0.09; 'whitespaces': 0.09; 'subject:python': 0.10; 'def': 0.13; '"""encode': 0.16; 'encode': 0.16; 'cc:addr:python-list': 0.16; 'this:': 0.16; 'wrote:': 0.18; 'any,': 0.18; 'this?': 0.19; 'cc:no real name:2**0': 0.20; "haven't": 0.20; 'header:In-Reply-To:1': 0.22; 'string': 0.24; 'cc:2**0': 0.24; 'code': 0.25; 'message- id:@mail.gmail.com': 0.28; 'subject: .': 0.29; 'unicode': 0.29; 'cc:addr:python.org': 0.29; "i'll": 0.31; 'there': 0.33; 'something': 0.35; 'subject:How': 0.35; 'received:209.85.161': 0.36; '8bit%:86': 0.37; 'but': 0.37; 'received:google.com': 0.37; 'think': 0.37; 'could': 0.37; 'received:209.85': 0.38; 'characters': 0.39; 'else': 0.39; 'received:209': 0.40; '2011': 0.61; 'achieve': 0.61; 'skip:\xd0 20': 0.77
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; bh=1LkyzkIJFSSKajveSrp7/mvEG8m4by9tv/hSgV4F9WE=; b=I1aFcbt/trdbXKRqfeevRF7mkkEl6tjaB/kDXb4N2shlWMumi8VM46EKSc8BhdEcnt jWL4dwdCpUBrZCzDJSnbRalitlF/pEXGGM9oJX6ft4YiYVEv5jbAYLc7P4viE2tBO95s EMOJ9jxP/Pp6PLgJU0Vf4b3vCONnwZHM3mGTw=
MIME-Version 1.0
In-Reply-To <jbj86t$r9e$1@dough.gmane.org>
References <CAJ6cK1aLyX0QSA3K3b+Rc+BPi9xZvbYJaEFk3-ijhdQWcdi9_w@mail.gmail.com> <jbj86t$r9e$1@dough.gmane.org>
Date Mon, 5 Dec 2011 20:25:39 +0000
Subject Re: How to generate java .properties files in python
From Arnaud Delobelle <arnodel@gmail.com>
To Serhiy Storchaka <storchaka@gmail.com>
Content-Type text/plain; charset=UTF-8
Content-Transfer-Encoding quoted-printable
Cc python-list@python.org
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.3320.1323116742.27778.python-list@python.org> (permalink)
Lines 26
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1323116742 news.xs4all.nl 6939 [2001:888:2000:d::a6]:56915
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:16685

Show key headers only | View raw


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


Thread

Re: How to generate java .properties files in python Arnaud Delobelle <arnodel@gmail.com> - 2011-12-05 20:25 +0000

csiph-web