Added:
- UAsc() returns Unicode value of UTF-8 codepoint
- UChr() returns UTF-8 codepoint of Unicode value
- UIvstr() returns True if string is valid UTF8
- URepair() Tries to repair UTF-8 string
Note: the functions UAsc() and UChr() will generate an "illegal function call" error when invalid codepoints are passed to them. So before using these functions on a UTF-8 string, be sure to have it checked first. See the following example on how to do that.
UIvstr() / URepair() example:
Code: Select all
dim as ustring s
's = chr(&h20AC) 'EURO sign
s = chr(&hC0) 'invalid UTF-8
if UIvstr(s) then
print "valid UTF-8 string"
else
URepair(s)
if UIvstr(s) then
print "UTF-8 string repaired"
else
print "UTF-8 string cannot be repaired"
end if
end if
end
Code: Select all
dim as uinteger a
dim as ustring c
a = &h20AC
c = UChr(a)
print c
a = UAsc(c)
print hex(a)
end