Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Python (http://www.velocityreviews.com/forums/f43-python.html)
-   -   Re: Convert unicode escape sequences to unicode in a file (http://www.velocityreviews.com/forums/t741874-re-convert-unicode-escape-sequences-to-unicode-in-a-file.html)

Jeremy 01-11-2011 11:39 PM

Re: Convert unicode escape sequences to unicode in a file
 
On Tuesday, January 11, 2011 3:36:26 PM UTC-7, Alex wrote:

>
> Are you _sure_ that your file contains the characters '\', 'u', '0',
> '0', 'e' and '9'? I expect that actually your file contains a byte
> with value 0xe9 and you have inspected the file using Python, which
> has printed the byte using a Unicode escape sequence. Open the file
> using a text editor or hex editor and look at the value at offset 947
> to be sure.
>
> If so, you need to replace 'unicode-escape' with the actual encoding
> of the file.


Yeah, I'm sure that's what the file contains. In fact, I solved my own problem while waiting for an answer. When writing to the file I need to *en*code instead of *de*code; i.e.,

o = open('newDice.sql', 'w')
o.write(utFound.encode('utf-8'))
o.close()

That works!


All times are GMT. The time now is 10:01 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.