Writing string from clipboard conataining æ ø å to file error

Asked by ithotline

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:
SikuliX Edit question
Assignee:
No assignee Edit question
Solved by:
masuo
Solved:
Last query:
Last reply:
Revision history for this message
Best masuo (masuo-ohara) said :
#1

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

Revision history for this message
ithotline (ithotline) said :
#2

Much apprechiated

Revision history for this message
ithotline (ithotline) said :
#3

Thanks masuo, that solved my question.