← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #193332]: find word in some string

 

Question #193332 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/193332

    Status: Open => Answered

RaiMan proposed the following answer:
--- file has utf-8 encoding already
This is the best case, since you have to do nothing else in your Sikuli scripts.
If you want to have choices and more features, use Notepad++ instead (http://notepad-plus-plus.org/). 
Coding: UTF-8 without BOM
(BOM would add additional 3 bytes at the beginning of the file!)

--- file does not have utf-8 encoding
This is normally the case, when saving files in Windows with normal Notepad (it is some extended ASCII encoding called ANSI or Latin-1(for WesternEurope), depends on the locale)

The following works, if there are embedded utf-8 characters in a file,
that is read as a byte string (normal operation):

infoText = []
xReader = file("C:\\Users\\fgandini\\Desktop\\infos.txt")
for line in xReader.readlines():
    infoText.append(line.strip().encode("utf-8"))

-- 
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.