On Saturday, 23 February 2013 16:06:11 UTC, Jussi Piitulainen wrote: > I don't know much of these things but I've been using Python's > json.dump and json.load for a couple of weeks now and they seem to use > ASCII-friendly escapes automatically, writing a four-character string > as "\u00e4\u00e4ni" instead of using the UTF-8 characters that my > environment is set to handle.
Thanks. When I tried to write a short program to demo what I was doing, I realised that my problem was actually with my test code, not with json. Here's my test code: import json, subprocess CODE=""" import json p = {'x': '\N{EURO SIGN}'} print json.dumps(p) """ data_bytes = subprocess.check_output(['py', '-2', '-c', CODE]) data = json.loads(data_bytes.decode('ASCII')) print(data) The problem is that I'm not using a raw string for CODE, so the Euro sign is being put into the string literally, and that causes all sorts of encoding-related fun that I didn't intend! As you say, json actually works fine for this application, so thanks for pointing that out. I thought it shouldn't need to be as hard as I was making it!!! Paul. -- http://mail.python.org/mailman/listinfo/python-list