Page 1 of 1
Removed: ASCII mode -- What dooes that mean??
Posted: Wed Jul 31, 2024 10:37 pm
by Randy Walker
25th July 2016 : Version 5.50
- Removed: ASCII mode for internal PureBasic string representation, PureBasic is now unicode only.
If PureBasic is now unicode only, does that mean *ALL* string funcrions are affected?
Trying to figure out what broke my code so it does not work on the 5.63 compiler and beyond.
I don't do unicode so I don't understand what it is, or how to adapt to this change.
Please pardon my ignorance

Re: Removed: ASCII mode -- What dooes that mean??
Posted: Wed Jul 31, 2024 11:12 pm
by idle
yes all strings are UCS2 encoded 2 bytes wide
you also have two pseudo types for use with imported function that only accept ascii or utf8 parameters p-ascii and p-utf8
and also two functions ascii(string) utf8(string) which return pointers you need to free them
It doesn't take long to adapt but yes it was a bit of an inconvenience at the time.
and also with latest 6.11 you need to check that your import parameters on x64 are right, a few got caught out using .l when we should have been using .i
Re: Removed: ASCII mode -- What dooes that mean??
Posted: Thu Aug 01, 2024 7:45 am
by infratec
We need to know waht you are doing at the location of the fault.
Else we can not provide a solution.
Re: Removed: ASCII mode -- What dooes that mean??
Posted: Thu Aug 01, 2024 7:51 am
by Randy Walker
Code: Select all
a$ ="B" ;single Byte
Debug a$ ; returns single byte
Debug Len(a$) ;confirms a$ is one Byte
So I'm confused. Where's the other Byte?
Re: Removed: ASCII mode -- What dooes that mean??
Posted: Thu Aug 01, 2024 7:56 am
by infratec
Code: Select all
a$ ="B" ;single Byte -> WRONG -> 2 bytes
Debug a$ ; returns single byte -> WRONG -> returns 1 character
Debug Len(a$) ;confirms a$ is one Byte -> WRONG -> confirms 1 character
Debug StringByteLength(a$) ; shows the truth
ShowMemoryViewer(@a$, StringByteLength(a$))
Re: Removed: ASCII mode -- What dooes that mean??
Posted: Thu Aug 01, 2024 8:33 am
by Randy Walker
oK infratec and thanks for clarifying. I guess I need to look in that direction. I was brought up on the understanding that a character = one Byte so I'm sure everything in my code is based on that assumption.
Re: Removed: ASCII mode -- What dooes that mean??
Posted: Thu Aug 01, 2024 8:54 am
by Mindphazer
Well, no matter if you are in ASCII mode or in Unicode mode, Len(a$) will always return 1 in your example.
So if you only work with a$, you should not see any difference
None of my applications ever had problems when PB turned from ASCII to Unicode...
Re: Removed: ASCII mode -- What dooes that mean??
Posted: Thu Aug 01, 2024 9:13 am
by AZJIO
Randy Walker
One character is now 2 bytes, no more difference. ASCII has many limitations; Linux uses UTF-8 by default.
Re: Removed: ASCII mode -- What dooes that mean??
Posted: Thu Aug 01, 2024 9:16 am
by Fred
Its an under-the-hood change, it shouldn't impact much applications unless you are dealing with external API which requiers ASCII/UTF8 inputs (ie: not PB commands).
Re: Removed: ASCII mode -- What dooes that mean??
Posted: Thu Aug 01, 2024 3:12 pm
by skywalk
Yes, it was fairly painless.
Code: Select all
Verify your source code:
Encode all source text files to UTF-8. (I use Notepad++ to confirm)
Use SizeOf(Character), not +1 for string terminations.
Change api prototypes exporting Ascii strings:
FROM: Prototype.i SendAscii(Dest.i, buf.s, nChars.i, *nCharsReturned_i)
TO: Prototype.i SendAscii(Dest.i, buf.p-Ascii, nChars.i, *nCharsReturned_i)
Re: Removed: ASCII mode -- What dooes that mean??
Posted: Thu Aug 01, 2024 3:35 pm
by Axolotl
If you only use the PB String Procedures, everything should be fine.
However, you should check older implementations that work with string pointers.
Because It can also happen within procedures that evaluate strings via pointers and do not use the Character type for this.
Just in case.