← Back to team overview

sikuli-driver team mailing list archive

[Bug 799929] Re: "&lang=" text can't be added to string

 

-- 1: prints a box for "&lang"
This is a "problem" of print. Since we are in a unicode aware environment, print does its work, which is to print out a "readable " representation of the given object.

Since we are with unicode, &lang (correctly ⟨) is the left angle
bracket, which seems to be a non-printeable character (therefor the box)
in your environment.

Everything else with the string works well, only finally, when you print
a string, that contains valid &xxxx;, they are converted to there
printable representations.

If you know, that your string might contain such elements, use this to get what you want:
x = "a string that contains &xxxx; elments (e.g. &lang=)"
print x # &lang replaced by angle bracket/box
print x.replace('&', '&') # & is the unicode representation of & (chr(38))
popup(x) # shows the string as it is

-- 2: loop seems not to work (second same as first)
since I do not see your loop construction, here a general example how it should work:

languages = ("de", "en", ko")
for lang in languages:
    print lang # use of each entry of languages in turn

-- 3: this is not a bug, but I will turn it into a question, since it
might help others

** Summary changed:

- "&lang=" text can't be added to string
+ print "&lang=" does not print the expected string --- workaround

** Description changed:

- I am setting a text constant to langtype = "&lang=". This and other text constants are being concatenated to form an html address that I paste into a Chrome address bar. It wasn't working, so I added a print command to see what Sikuli was doing. It is changing this constant to a box character, as if it doesn't understand the constant. I've tried moving the constant to the beginning and end of the text; it doesn't seem to matter. 
+ *** workaround ***
+ see comment #2
+ use instead:
+ 
+ x = "a string that contains &xxxx; elments (e.g. &lang=)"
+ print x.replace('&', '&') # & is unicode repr. of & (chr(38))
+ 
+ ---------------------------------------------
+ I am setting a text constant to langtype = "&lang=". This and other text constants are being concatenated to form an html address that I paste into a Chrome address bar. It wasn't working, so I added a print command to see what Sikuli was doing. It is changing this constant to a box character, as if it doesn't understand the constant. I've tried moving the constant to the beginning and end of the text; it doesn't seem to matter.
  What's really odd is that I am concatenating a language string so my page loads in a different language each time. I have these languages stored in an array. The first language loads ok, but the second loads the previous language. The print shows me each time that Sikuli is using a box instead of the text.
  I'm on Sikuli X-1.0rc2, on a 32bit Windows XP system.
  I don't get any errors. The script loads the correct language in the address the first time, but the second time through the loop, I get the first language again.

-- 
You received this bug notification because you are a member of Sikuli
Drivers, which is subscribed to Sikuli.
https://bugs.launchpad.net/bugs/799929

Title:
  print "&lang=" does not print the expected string --- workaround

Status in Sikuli:
  Invalid

Bug description:
  *** workaround ***
  see comment #2
  use instead:

  x = "a string that contains &xxxx; elments (e.g. &lang=)"
  print x.replace('&', '&') # & is unicode repr. of & (chr(38))

  ---------------------------------------------
  I am setting a text constant to langtype = "&lang=". This and other text constants are being concatenated to form an html address that I paste into a Chrome address bar. It wasn't working, so I added a print command to see what Sikuli was doing. It is changing this constant to a box character, as if it doesn't understand the constant. I've tried moving the constant to the beginning and end of the text; it doesn't seem to matter.
  What's really odd is that I am concatenating a language string so my page loads in a different language each time. I have these languages stored in an array. The first language loads ok, but the second loads the previous language. The print shows me each time that Sikuli is using a box instead of the text.
  I'm on Sikuli X-1.0rc2, on a 32bit Windows XP system.
  I don't get any errors. The script loads the correct language in the address the first time, but the second time through the loop, I get the first language again.

To manage notifications about this bug go to:
https://bugs.launchpad.net/sikuli/+bug/799929/+subscriptions


References