Because PB is unicode, update UTF8() and ASCII()

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
Mesa
Enthusiast
Enthusiast
Posts: 433
Joined: Fri Feb 24, 2012 10:19 am

Because PB is unicode, update UTF8() and ASCII()

Post by Mesa »

The PEEKS() function is too often used with these functions so we could simplify the code with an update of UTF8() and ASCII() like that:

*Buffer = UTF8(String$, StringUTF8$)
*Buffer = ASCII(String$, StringASCII$)


Example:
ASCII("OK", ASCII$)
Debug ASCII$

M.
infratec
Always Here
Always Here
Posts: 7588
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: Because PB is unicode, update UTF8() and ASCII()

Post by infratec »

Hi,

you have not fully understand what the procedures do.
What you want is on one side not possible and on the other it results in memory leaks.

Case 1
If you convert a normal string to ascii, you can not use debug to show it, because it is no longer in unicode.
You can check this with the memoryviewer.

Case 2
On the other side, if you have a procedure like

*Buffer = Unicode(String$, StringASCII$)

you forget to free the buffer and you have a memory leak.


Bernd
Post Reply