Removed: ASCII mode -- What dooes that mean??

Just starting out? Need help? Post your questions and find answers here.
Randy Walker
Addict
Addict
Posts: 1109
Joined: Sun Jul 25, 2004 4:21 pm
Location: USoA

Removed: ASCII mode -- What dooes that mean??

Post 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 :oops:
- - - - - - - - - - - - - - - -
Randy
I *never* claimed to be a programmer.
User avatar
idle
Always Here
Always Here
Posts: 6026
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: Removed: ASCII mode -- What dooes that mean??

Post 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
infratec
Always Here
Always Here
Posts: 7662
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: Removed: ASCII mode -- What dooes that mean??

Post by infratec »

We need to know waht you are doing at the location of the fault.
Else we can not provide a solution.
Randy Walker
Addict
Addict
Posts: 1109
Joined: Sun Jul 25, 2004 4:21 pm
Location: USoA

Re: Removed: ASCII mode -- What dooes that mean??

Post 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?
- - - - - - - - - - - - - - - -
Randy
I *never* claimed to be a programmer.
infratec
Always Here
Always Here
Posts: 7662
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: Removed: ASCII mode -- What dooes that mean??

Post 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$))
Randy Walker
Addict
Addict
Posts: 1109
Joined: Sun Jul 25, 2004 4:21 pm
Location: USoA

Re: Removed: ASCII mode -- What dooes that mean??

Post 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.
- - - - - - - - - - - - - - - -
Randy
I *never* claimed to be a programmer.
User avatar
Mindphazer
Enthusiast
Enthusiast
Posts: 487
Joined: Mon Sep 10, 2012 10:41 am
Location: Savoie

Re: Removed: ASCII mode -- What dooes that mean??

Post 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...
MacBook Pro 16" M4 Pro - 24 Gb - MacOS 15.4.1 - Iphone 15 Pro Max - iPad at home
...and unfortunately... Windows at work...
AZJIO
Addict
Addict
Posts: 2225
Joined: Sun May 14, 2017 1:48 am

Re: Removed: ASCII mode -- What dooes that mean??

Post by AZJIO »

Randy Walker
One character is now 2 bytes, no more difference. ASCII has many limitations; Linux uses UTF-8 by default.
Fred
Administrator
Administrator
Posts: 18351
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: Removed: ASCII mode -- What dooes that mean??

Post 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).
User avatar
skywalk
Addict
Addict
Posts: 4242
Joined: Wed Dec 23, 2009 10:14 pm
Location: Boston, MA

Re: Removed: ASCII mode -- What dooes that mean??

Post 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)
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
Axolotl
Addict
Addict
Posts: 872
Joined: Wed Dec 31, 2008 3:36 pm

Re: Removed: ASCII mode -- What dooes that mean??

Post 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.
Just because it worked doesn't mean it works.
PureBasic 6.04 (x86) and <latest stable version and current alpha/beta> (x64) on Windows 11 Home. Now started with Linux (VM: Ubuntu 22.04).
Post Reply