Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Python (http://www.velocityreviews.com/forums/f43-python.html)
-   -   Unicode support (http://www.velocityreviews.com/forums/t334030-unicode-support.html)

Richy2004 08-06-2004 01:44 PM

Unicode support
 
I've experienced problems when trying to load a text file encoded with
2byte unicode characters. No matter what combination of the following
I try, I always get an error when
executing file.readline()

file = open("file.txt", "r")
file = open("file.txt", "rb")
file = codecs.open("file.txt", "rb", "utf-16")
file = unicode(open("file.txt", "r"), "utf-16")

Even more strangely it does work when used in the interactive
interpreter.

Any ideas?

Thanks,
Richard


Peter Hansen 08-06-2004 01:52 PM

Re: Unicode support
 
Richy2004 wrote:

> I've experienced problems when trying to load a text file encoded with
> 2byte unicode characters. No matter what combination of the following
> I try, I always get an error when
> executing file.readline()
>
> file = open("file.txt", "r")
> file = open("file.txt", "rb")
> file = codecs.open("file.txt", "rb", "utf-16")
> file = unicode(open("file.txt", "r"), "utf-16")
>
> Even more strangely it does work when used in the interactive
> interpreter.
>
> Any ideas?


Always post the actual traceback (cut and pasted from another window)
when saying you are getting an error. That avoids lots of guessing
on our part as to what is going on.

-Peter


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

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


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57