Is there any reason to prefer
unicode(somestring, 'utf8') as opposed to
My only thought is that .decode() is a bound method so python may be able to resolve it more efficiently, ...
This is in python 2.4. Here is my situation. I pull a string from a database, and it contains an umlauted 'o' (\xf6). At this point if I run type(value) it ...
I have terminal.app set to accept utf-8 and in bash I can type unicode characters, copy and paste them, but if I start the python shell I can't and if I ...
I've got a problem with strings that I get from one of my clients over xmlrpc. He sends me utf8 strings that are encoded twice :( so when I get them ...
I'm using python's base64 module and I get a string that can be encoded or not encoded. I would like to do something like:
output = base64.decodestring(s)
I'm writing a parser, and there is LOTS of text to decode but most of my users will only care about a few fields from all the data. So I only ...
Inside my python scrip, I get some string back from a function which I didn't write. The encoding of it varies. I need to convert it to ascii format. Is there ...
What would the best way of unpacking a python string into fields
I have data received from a tcp socket, it is packed as follows, I believe it will be in a ...
s = 'Tara%2520Stiles%2520Living'
How do I turn it into:
Tara Stiles Living
I am trying to parse a CSV file containing some data, mostly numeral but with some strings - which I do not know their encoding, but I do know they are ...
Trying to decode an invalid encoded utf-8 html page gives different results in
python, firefox and chrome.
The invalid encoded fragment from test page looks like
>>> fragment = 'PREFIX\xe3\xabSUFFIX'
>>> fragment.decode('utf-8', 'strict')
UnicodeDecodeError: 'utf8' ...
it works fine on 64 bit machines but for some reason will not work on python 2.4.3 on a 32-bit instance.
i get the error
'utf8' codec can't decode bytes in position ...
I have an old C# program that is being ported to Python 3 for different reasons. Basically, what the program does is to fetch a website and search its content (and ...
In a text file (test.txt), my string looks like this:
Reading it, python escapes the backslash:
>>> file = open('test.txt', 'r')
>>> input = file.readline()
How can I have this interpreted as unicode?
When profiling our code I was surprised to find millions of calls to
I started debugging and found that across our code base there are many small bugs, ...
Platform: App Engine
Framework: webapp / CGI / WSGI
On my client side (JS), I construct a URL by concatenating a URL with an unicode string:
then I call encodeURI to get
and I put ...
In Python 2, converting the hexadecimal form of a string into the corresponding unicode was straightforward:
where the variable 'comments' is a part of a line in a file (the rest of ...
Can someone give an advice of how to decode these strings?
They are parts of email subjects.
It's probably necessary to take inner part of string
ICLRLcvu5Obo8fLo6iI and then
Such an approach ...
I'm using BeautifulSoup, and I get back a string like this:
It's a unicode, but what I want is to make it look like:
I have tried
name = name.encode('utf-8'), decode(), ...
Hi, I have this string which is what returned from an IMAP command - do anyone know how to decode this in python so I'll have the proper UTF-8 string?
This is the code:
>>> import base64
>>> id = 1
>>> key = "secret key very long"
>>> enc = base64.urlsafe_b64encode(str(id)+key)
'1secret key very long'
Works as intended on my machine, but when I ...
I have some strings with all this kind of characters in it which also has normal letters ,
and i want to transform all the "wired" characters in they're normal representation .
I've got what's supposed to be a UCS-2 encoded xml document that I've managed to build a DOM based on minidom after some tweaking.
The issue is that I'm supposed to have ...
I am reading a first and last name in Python from a file and am having trouble with encoding. I want to print out the name, but am getting "UnicodeEncodeError: 'charmap' ...
I have a string from reading a .txt file that looks something like this:
The contents of the file is in Portuguese and it won't allow me to encode into utf-8.
When I ...
I'm having some trouble with Python's raw_input command (Python2.6),
For some reason, the raw_input does not get the converted string that swedify() produces and this giving me a encoding error which i'm ...
i have file having name
"SSE-Künden, SSE-Händler.pdf" which having those two
unicode char ( ü,ä) when i am printing this file name on python interpreter the unicode values are getting ...
Writing my code for Python 2.6, but with Python 3 in mind, I thought it was a good idea to put
from __future__ import unicode_literals
at the top of some modules. In other ...
I get the following string from database:
'23:45 \xe2\x80\x93 23:59'
and the output should look like
'23:45 - 23:59'
How can I decode this? I tried utf-8 ...
string.decode('hex') by ScoutDavid Sun Apr 03, 2011 11:50 am I have this string: Code: Select all myString = "DE2A2A" And then I try to decode it, by doing myString.decode('hex'). If you try it in IDLE you'll get it fine, but in the middle of my program, I get this: Code: Select all Traceback (most recent call last): File ...