I'm passing utf-8 encoded string as text to VirtualKeyboard
Screen <class 'Screens.VirtualKeyBoard.VirtualKeyBoard'>(('Editova\xc5\xa5 n\xc3\xa1zov s\xc3\xbaboru',), {'text': 'HDTV by Lidu\xc5\xa1ka(Broadchurch.S02E04.HDTV'}): <type 'exceptions.UnicodeEncodeError'>
Traceback (most recent call last):
File "/usr/local/e2/lib/enigma2/python/mytest.py", line 226, in create
return screen(self, *arguments, **kwargs)
File "/usr/local/e2/lib/enigma2/python/Screens/VirtualKeyBoard.py", line 74, in __init__
self["text"] = Input(currPos=len(kwargs.get("text", "").decode("utf-8",'ignore')), allMarked=False, **kwargs)
File "/usr/local/e2/lib/enigma2/python/Components/Input.py", line 25, in __init__
self.setText(text)
File "/usr/local/e2/lib/enigma2/python/Components/Input.py", line 65, in setText
self.Text = text.decode("utf-8", "ignore").decode("utf-8")
File "/usr/lib/python2.7/encodings/utf_8.py", line 16, in decode
return codecs.utf_8_decode(input, errors, True)
UnicodeEncodeError: 'ascii' codec can't encode character u'\u0161' in position 12: ordinal not in range(128)
Traceback (most recent call last):
File "/usr/local/e2/lib/enigma2/python/Components/ActionMap.py", line 46, in action
res = self.actions[action]()
File "/usr/local/e2/lib/enigma2/python/Plugins/Extensions/SubsSupport/subtitles.py", line 3760, in editFName
self.session.openWithCallback(editFnameCB, VirtualKeyBoard, _("Edit Filename"), text= toString(self["fname"].text.strip()))
File "/usr/local/e2/lib/enigma2/python/mytest.py", line 294, in openWithCallback
dlg = self.open(screen, *arguments, **kwargs)
File "/usr/local/e2/lib/enigma2/python/mytest.py", line 305, in open
dlg.isTmp = True
AttributeError: 'NoneType' object has no attribute 'isTmp'
Sorry guys, you're right, self.Text has to be unicode, and self.text utf-8 encoded string.
This should be alright... please check
diff --git a/lib/python/Components/Input.py b/lib/python/Components/Input.py
index 680e95d..a1afe33 100644
--- a/lib/python/Components/Input.py
+++ b/lib/python/Components/Input.py
@@ -62,7 +62,7 @@ class Input(VariableText, HTMLComponent, GUIComponent, NumericalTextInput):
self.currPos = 0
self.Text = u""
else:
- self.Text = text.decode("utf-8", "ignore").decode("utf-8")
+ self.Text = text.decode("utf-8", "ignore")
self.update()
def getText(self):
@@ -152,7 +152,7 @@ class Input(VariableText, HTMLComponent, GUIComponent, NumericalTextInput):
self.update()
def insertChar(self, ch, pos=False, owr=False, ins=False):
- self.Text = self.Text.decode("utf-8", "ignore").decode("utf-8")
+ self.Text = self.Text.decode("utf-8", "ignore")
if not pos:
pos = self.currPos
if ins and not self.maxSize:
Edited by mx3L, 21 February 2015 - 23:31.