Page 1 of 1

Asc() and Chr() for Unicode, UTF-8

Posted: Thu Nov 08, 2012 3:06 pm
by Psychophanta
Asc() and Chr() functions for Unicode, UTF-8, and maybe also for the UTF-16
Adding the parameter [, Format] to those functions would be good.

Re: Asc() and Chr() for Unicode, UTF-8

Posted: Thu Nov 08, 2012 3:15 pm
by STARGÅTE
Chr() and Asc() already working with Unicode.

Code: Select all

Debug Asc("€")
8364

Code: Select all

Debug Chr(8364)
UTF-8 is not necessary because a string in PureBasic can exist only as ascii or unicode

Re: Asc() and Chr() for Unicode, UTF-8

Posted: Thu Nov 08, 2012 3:38 pm
by Psychophanta
Yes ther looks like it works:

Code: Select all

For t.l=0 To 65535
  If Asc(Chr(t))<>t
    Debug "error"
  EndIf
Next
But only if compiled as unicode.

Re: Asc() and Chr() for Unicode, UTF-8

Posted: Fri Nov 09, 2012 5:27 am
by Regenduft
You can use PokeS() with #PB_Ascii or #PB_Unicode flag and PeekC() afterwards to get what you want. Since PokeS() also alway writes the terminating #NUL$ this works in any case.