Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to deal with unicode in strings?
#3
a couple more options
#1 you can use this member function

Member function str.getU2
Code:
Copy      Help
function$ $sinp from nc

;Unicode version 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
  for your example would use like so
Function UnicodeTest1
Code:
Copy      Help
str s.getclip;
paste s
str b.getU2(s 0 1);; gets first character
paste b

#ret;;for testing place cursor on line below and run

#2 can use paste with format fields
Function UnicodeTest2
Code:
Copy      Help
str s.getclip;
paste s;
paste("%#.1s" s);; paste first character of string

#ret;;for testing place cursor on line below and run


Messages In This Thread
How to deal with unicode in strings? - by MBaas - 08-04-2021, 08:08 AM
RE: How to deal with unicode in strings? - by Kevin - 08-05-2021, 02:40 PM

Forum Jump:


Users browsing this thread: 2 Guest(s)