special character ñ

Asked by alonso

I can't use character ñ (very common in Spanish) on any string used with Type

¿any suggestion on how i can solve this ?

thanks

Question information

Language:
English Edit question
Status:
Answered
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Tsung-Hsiang Chang (vgod) said :
#1

Try a new command in 0.9.7, paste().
This should avoid the problem of typing international characters.
However, it uses clipboard to transfer text, so beware that it will also mess up your clipboard.

Revision history for this message
Deses (deses12) said :
#2

(I don't feel like opening a new question if there is already this one, if that's wrong, tell me.)

Two years after this question, this has not been fixed yet, as I just encountered the same problem.

I can't Type ñ, or vowels with accents. :(

I tried to adding "#-*-coding: iso-8859-15-*-" at the beginning of the script, like I did back when I used python, but it raises a SyntaxError exception.

There is something similar for Jython?

Revision history for this message
Deses (deses12) said :
#3

Sorry to spam this thread, but I don't know or see anything to edit my comment.

Well, I added "# -*- coding utf-8 -*-" and now it doesn't raise an exception, but it's still not working.

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

@Deses
type() definitely does not work with non-us keyboards and cannot be used for most special characters, especially all characters having a non ascii representation.
This is still valid with Sikuli's newest version X-1.0rc3.

# -*- coding utf-8 -*-
only means, that you can use utf-8 characters in your script. This does not mean anything for type().
This is no longer needed with the newest version.

conclusion: use paste() instead of type() (as already mentioned in the first comment)

Revision history for this message
Pacha95 (laurent-peytoureau) said :
#5

@RaiMan

Using windows7 and a french keyborad, I've tried :
  paste("éléphant\n")
and the result is
  Ã©léphant

Unfortunately, it seems that "paste" doesn't solve all issues with no US Keyboard !!!

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

@Laurent
I can reproduce this problem in my german locale.

But this solves it:
paste(unicode("éléphant\n", "utf8"))

with version 1.0.1 there is a shortcut available: unicd(some_string)
paste(unicd("éléphant\n"))

I will make this a bug about paste, since this should be solved more generally.
Thanks for finding.

Revision history for this message
Pacha95 (laurent-peytoureau) said :
#7

Thanks RaiMan for your solution.
Of course, it works perfectly on Windows system.
I hope it works also on LINUX system, I'll test tomorow !

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

should do, because this is something between Jython and Java (not system dependent).

BTW: I tested on the "best" Unix available: Mac OSX 10.9 ;-)

Revision history for this message
Pacha95 (laurent-peytoureau) said :
#9

OK RaiMan, thanks for your tests.
I also made some complementary tests on windows and I find this :

paste(unicd("first line\n"))
paste(unicd("second line\n"))
paste(unicd("last line\n"))

gives :

first linesecond linelast line

but :

paste(unicd("first line\n "))
paste(unicd("second line\n "))
paste(unicd("last line\n "))

gives :

first line
 second line
 last line

It seems the "\n" is not taken into account on the first test.
I've added a space after "\n" in the second test and it's better but the space appears at the beginning of the next line...

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

OK, another mystery to be evaluated ;-)

I never use \n in paste()

I always use
paste(some_text)
type(Key.ENTER) # which too has some implications in some situations

what about this in your situation?

Revision history for this message
Pacha95 (laurent-peytoureau) said :
#11

Your solution is right, Another one could be :

paste(unicd("first line\n\n"))
paste(unicd("second line\n\n"))
paste(unicd("last line\n\n"))

which gives exactly what I needed (no space at beginnig of the lines)

first line
second line
last line

Same result with :

paste(unicd("first line\nsecond line\nlast line\n\n"))

Thanks a lot for your help ;-)

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

ok, thanks.

Seems to be, that Jython has a bug/restriction, that a \n at the end of a string is ignored.
I will check that.

Can you help with this problem?

Provide an answer of your own, or ask alonso for more information if necessary.

To post a message you must log in.