Writing string from clipboard conataining æ ø å to file error

Asked by ithotline on 2019-12-03

when copying text containing æ. ø or å i get this error

[error] UnicodeDecodeError ( 'ascii' codec can't decode byte 0xc3 in position 36: ordinal not in range(128) )

I have tried different approaches without luck

This is my code
type("c", KEY_CTRL)
cb = Env.getClipboard().strip().encode("utf-8")
my_file.write(cb + Key.ENTER)

Error:

error] script [ pallex ] stopped with error in line 14
[error] UnicodeDecodeError ( 'ascii' codec can't decode byte 0xc3 in position 36: ordinal not in range(128) )
[error] --- Traceback --- error source first
line: module ( function ) statement
14: main ( <module> ) my_file.write(cb + Key.ENTER)
[error] --- Traceback --- end --------------

Question information

Language:
English Edit question
Status:
Solved
For:
Sikuli Edit question
Assignee:
No assignee Edit question
Solved by:
masuo
Solved:
2019-12-06
Last query:
2019-12-06
Last reply:
2019-12-04
Best masuo (masuo-ohara) said : #1

try my_file.write(cb + "\n") instead of my_file.write(cb + Key.ENTER)

ithotline (ithotline) said : #2

Much apprechiated

ithotline (ithotline) said : #3

Thanks masuo, that solved my question.