double byte chars?
Lars Brehmer
larsbrehmer at mac.com
Sat Jun 11 14:14:03 EDT 2011
My project has Russian text fields (Arial,Russian). With one exception, everything works fine.
Problem: a filter-as-you-type script.
field "t1": зо
field "t2": меня зовут Виктор --underscoring shows the matches--
field "t3": зовут курить почему
I want to do is find a word in fields t2 and t3 that begins with the 2 letters in field t1. Word 2 in field t2 and word 1 in field t3 should be matches. But this only works if the matching word is the first word in the field!
Some simple message box scripts:
put fld "t1" & cr & fld "t2" & cr & fld "t3"
The result is a bunch of numbers, symbols and squares. You can clearly spot the matches.
Next in the message box: --char 1 to 4 -- double byte chars--
put char 1 to 4 in fld "t1" into aText
put char 1 to 4 in word 2 in fld "t2" into bText
put char 1 to 4 in word 1 in fld "t3" into cText
put aText & cr & bText & cr & cText
This should be 3 identical lines, right? But no. Line 2 is missing the final char.
7(square)>(square)
7(square)>
7(square)>(square)
Next: comparing the strings
if cText = aText then beep - it beeps
if cText is in aText then beep - it beeps
if bText = aText then beep - no beep, obviously
BUT
if bText is in aText then beep - also no beep!
And then
put char 1 to 5 in word 2 in field "t2", it returns the same as the other two:
7(square)>(square)
so then
put char 1 to 5 in word 2 into bText
but
if bText = (or is in) aText still returns nothing
Why is that last double byte char always missing when the word is not word 1 in its field? If I do char 1 to 3 I get this (again!)
7(square)>
7(square) --last char missing!
7(square)>
Using itemDEL = space and char 1 to x in item z behaves the same.
Anyone know the answer?
Cheers,
Lars
More information about the use-livecode
mailing list