How to use utf-8 unicode characters with input() and popup()

Asked by obaskirt

*** solution

--- input("a unicode string")
here it is just enough to tell Jython, that the string contains unicode characters:

a=input(u"Enter a Sayı")

--- answer = input("hello")
if it might be, that the returned string in answer contains utf-8 unicode characters, you have to write:

answer = input("hello").encode("utf-8")

if answer is used with functions that are not unicode aware (like print).

--- popup()
itself is unicode aware

answer = input("hello")
popup(answer)

works correctly, if answer contains unicode characters.

--------------------------------------------------------------------------------

My question is very simple and easy
I am trying to use Turkish character "ı, ş, ü, ö, ç, ğ" with input function. But I can not see them correctly when I am running the code. How can I solve this problem?

a=input("Enter a Sayı")
popup(a)

Question information

Language:
English Edit question
Status:
Solved
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Solved by:
obaskirt
Solved:
Last query:
Last reply:
Revision history for this message
obaskirt (onur-baskirt) said :
#1

I solved this problem in this way.
value = unicode("Enter a Sayı", "utf-8")
a=input(value)
popup(a)

Revision history for this message
RaiMan (raimund-hocke) said :
#2

--- input("a unicode string")
here it is just enough to tell Jython, that the string contains unicode characters:

a=input(u"Enter a Sayı")

--- answer = input("hello")
if it might be, that the returned string in answer contains utf-8 unicode characters, you have to write:

answer = input("hello").encode("utf-8")

Revision history for this message
RaiMan (raimund-hocke) said :
#3

--- popup()
itself is unicode aware

answer = input("hello")
popup(answer)

works correctly, if answer contains unicode characters.