← 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: Answered => Open

fernando gandini is still having a problem:
Hi RaiMan, tanks a lot for the answers.....

but now i have another strange problem...

read from UTF-8 file --------
Fernando Gandini
Física
-------------------------------------------------------------------------
infoText = []
xReader = file("C:\\Users\\fgandini\\Desktop\\infos2.txt")
for line in xReader:
    line.rstrip("\n")
    infoText.append(line.strip())

popup(infoText[1])
if (infoText[1] == "Física"):
    popup("certo")
else:
    popup("errado")
print infoText[1]
exit()
---------------------------------------
popup(infoText[1]) ------> appear with wrong encoding
if (infoText[1] == "Física"): --------> return true, so read the file with
correct encode
print infoText[1]   ------------>   appear correct in the console


2012/4/12 RaiMan <question193332@xxxxxxxxxxxxxxxxxxxxx>

> Your 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"))
>
> --
> If this answers your question, please go to the following page to let us
> know that it is solved:
> https://answers.launchpad.net/sikuli/+question/193332/+confirm?answer_id=6
>
> If you still need help, you can reply to this email or go to the
> following page to enter your feedback:
> https://answers.launchpad.net/sikuli/+question/193332
>
> You received this question notification because you asked the question.
>

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