why can't I decode a string to mbcs under Linux?I can do this in Windows:
a='你好'.decode('mbcs')
when I decode a string to 'mbcs ',the error message is:
[root@localhost EditPage]# python main.py
Traceback (most recent call last):
File "main.py", line 176, in ?
app = _MyApp(0)
File "/usr/local/lib/python2.3/site-packages/wxPython/wx.py", line 1939, in
__init__
_wxStart(self.OnInit)
File "main.py", line 166, in OnInit
self.frame = _myFrame(None, -1, "")
File "main.py", line 161, in __init__
self.edit_page.demo()
File "main.py", line 136, in demo
tc.SetText('hello,good moring!你好'.decode('mbcs'))
File "/usr/local/lib/python2.3/encodings/__init__.py", line 84, in
search_function
globals(), locals(), _import_tail)
File "/usr/local/lib/python2.3/encodings/mbcs.py", line 14, in ?
class Codec(codecs.Codec):
File "/usr/local/lib/python2.3/encodings/mbcs.py", line 18, in Codec
encode = codecs.mbcs_encode
AttributeError: 'module' object has no attribute 'mbcs_encode'
···
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
why can't I decode a string to mbcs under Linux?I can do this in Windows:
a='你好'.decode('mbcs')
when I decode a string to 'mbcs ',the error message is:
[root@localhost EditPage]# python main.py
Traceback (most recent call last):
File "main.py", line 176, in ?
app = _MyApp(0)
File "/usr/local/lib/python2.3/site-packages/wxPython/wx.py", line 1939, in
__init__
_wxStart(self.OnInit)
File "main.py", line 166, in OnInit
self.frame = _myFrame(None, -1, "")
File "main.py", line 161, in __init__
self.edit_page.demo()
File "main.py", line 136, in demo
tc.SetText('hello,good moring!你好'.decode('mbcs'))
File "/usr/local/lib/python2.3/encodings/__init__.py", line 84, in
search_function
globals(), locals(), _import_tail)
File "/usr/local/lib/python2.3/encodings/mbcs.py", line 14, in ?
class Codec(codecs.Codec):
File "/usr/local/lib/python2.3/encodings/mbcs.py", line 18, in Codec
encode = codecs.mbcs_encode
AttributeError: 'module' object has no attribute 'mbcs_encode'
Because of exactly what it says. The _codecs module has no mbcs_encode
function on Linux. Beyond that you'll have to ask the Python folks why.
···
--
Robin Dunn
Software Craftsman http://wxPython.org Java give you jitters? Relax with wxPython!