Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Get with unicode strings
#1
Dear Gintaras,

I understand that "get" does not work with unicode strings. Therefore, I implemented the following code to do it :
Member function str.getU
Code:
Copy      Help
function~ str'sinp int'from int'nc
;Unicode versdion of "get" macro, it also serves left
str s=sinp
s.unicode ;;convert to UTF-16
str s1.get(s 2*from 2*nc)
s1.ansi
this=s1

I wonder whether you have any relevant comments. Regards, Thanks.
#2
Some changes.
Member function str.getU2
Code:
Copy      Help
function$ $sinp from nc

;Unicode versdion of "get" macro, it also serves left

;Error if from invalid.
;If nc < 0 or too big, gets all right part.

str s.unicode(sinp) ;;convert to UTF-16
from*2; nc*2
if(from<0 or from>s.len) end ERR_BADARG
if(nc<0 or from+nc>s.len) nc=s.len-from
this.ansi(s+from -1 nc/2)
ret this
#3
Many thanks. I think that nc should not be doubled in this version.
Regards, Simos.
#4
Yes, added /2


Forum Jump:


Users browsing this thread: 1 Guest(s)