Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Unicode character length and moving text cursor
#1
Hi,

I want to move the text cursor before the first letter o, and the result of macro M1 execution is correct, the result of macro M2 execution is incorrect

In utf8 mode, a unicode character occupies 3 bytes. How do I determine it and move it correctly?

Or, I need to move a unicode character as the length of a letter

Thanks in advance for any suggestions and assistance
david


Macro M1
 
Code:
Copy      Help
_s="hello, world"
_i=find(_s "o")
_i=_s.len-_i

paste _s
'L (#_i) ;;OK

Macro M2
Code:
Copy      Help
_s="hello你好,世界world"
_i=find(_s "o")
_i=_s.len-_i

paste _s
'L (#_i) ;;NO
#2
Code:
Copy      Help
_s="hello你好,世界world"
BSTR s=_s
_i=find(s "o")
paste _s
'L (#s.len-_i)
#ret ;; place cursor on line below here and run
#3
kevin,thank you so much!
#4
If there are multiple lines, I will use the following code. Is there a simpler one?

Code:
Copy      Help
(#s.len-_i-numlines(s)+1)

Macro M3
Code:
Copy      Help
_s=
;hello你好
;world
;世界world
BSTR s=_s
_i=find(s "e")

paste _s
'L (#s.len-_i-numlines(s)+1)


Forum Jump:


Users browsing this thread: 1 Guest(s)