I'm now on Ubuntu 13.04 and Python 2.7.4 and tried to run a script including the following lines:
html = unicode(html, 'cp932').encode('utf-8')
html1, html2 = html.split(some_text) # this line spits out the error
However, when I ran the above script on Ubuntu 13.04, it spitted out an error UnicodeDecodeError: 'ascii' codec can't decode byte 0xe3 in position 106: ordinal not in range(128)
. However, this exactly same script can always be executed successfully on OS X 10.8 and Python 2.7.3. So I wonder why the error occurred only one of the two platforms...
The first thought came to my mind, especially after reading this post (UnicodeDecodeError: 'ascii' codec can't decode byte 0xef in position 1) was that the dichotomy arose because I'm in a different LANG
environment, where I use jp_JP.UTF-8
on OS X but en_US.UTF-8
on Ubuntu. So I also tried to add one more line os.environ['LANG'] = 'jp_JP.UTF-8'
to the aforementioned scrip, but still got the same error.
One more strange phenomenon is that when I attempt to run the script from within IPython shell on Ubuntu and go into debug mode immediately after the error happens, and then run the line which originally triggered the error, I don't get the error any more...
So what's happening here? And what am I missing?
Thanks in advance.