-1

alphabet keys(a-z) numeric keys(0-9) are mapped to unicode values, in a text editor which uses the wx.TextCtrl.

The line in which error encounters is given below,

self.statusbar.SetStatusText(engine.roman2mal(self.word.decode('utf-8')),0)

The error message is as given below,

Traceback (most recent call last):
  File "F:\EZHUTHANI_WIN\ezhuthani\beditor.py", line 498, in PreviewConv
    self.statusbar.SetStatusText(engine.roman2mal(self.word.decode('utf-8')),0)
  File "C:\Python27\lib\encodings\utf_8.py", line 16, in decode
    return codecs.utf_8_decode(input, errors, True)
UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-5: ordinal not in range(128)

Is there a way to map these keys(Enter, Space Bar, Backspace)? the other keys are mapped as given below,

keymap = {}
keymap['a'] = u'\u0D05';
keymap['A'] = u'\u0D06';
chris
  • 190
  • 1
  • 14

2 Answers2

1

I'm not entirely sure what you to achieve, but it sounds like you want to be using

wx.WXK_BACK
wx.WXK_ESCAPE
wx.WXK_RETURN
...

perhaps

keymap = {}
keymap[wx.WXK_ESCAPE] = u'<ESCAPE>'
...
Ross
  • 206
  • 1
  • 6
1
self.statusbar.SetStatusText(engine.roman2mal(self.word.decode('utf-8')),0) 

You have to remove .decode function then the code will look like

 self.statusbar.SetStatusText(engine.roman2mal(self.word),0) 
  • 1
    solved the issue... the code had the decode?encode functions used in multiple places. it didn't actually had to do that since python can print the unicode characters without it. – chris Jun 21 '13 at 06:37