Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
QM 2.3.0.0 - Unicode Characters Selection - Bytes and Charac
#1
QM 2.3.0.0 - Unicode Characters Selection - Bytes and Characters

Using

i=findrx(s rx i flags|8 length)

it obtains position (i) and length (length) in bytes.

To select found string using findrx :

SendMessage(h EM_SETSEL i i+length)

where "i and length" in the above statement refer to unicode characters, not to bytes.

Any idea about the way to bridge the gap between numbers of unicode characters and unicode bytes?
#2
To calculate length in characters, convert to UTF-16.

Macro
Code:
Copy      Help
int h=id(15 "Notepad")
str s="ψω_ϐϒ *"
s.setwintext(h)

int i length flags
str rx="_\S+"
i=findrx(s rx i flags|8 length)
if(i<0) ret

str s1.get(s 0 i) s2.get(s i length) ;;get substrings of needed length
s1.unicode; s2.unicode ;;convert to UTF-16
i=s1.len/2; length=s2.len/2 ;;num bytes to num chars

SendMessage(h EM_SETSEL i i+length)
#3
Gintaras,

Many thanks, it works perfectly.

Once more again congratulations for 2.3.0.

Regards

Simos


Forum Jump:


Users browsing this thread: 1 Guest(s)