For programs compiled in ASCII :
Code: Select all
PokeS(*memory, source.s,-1, #PB_Unicode) ;would convert a string from the default format of ASCII to a Unicode string located at *memory
destination.s=PeekS(*memory,-1, #PB_Unicode) ;would convert a string at *memory from Unicode to the default ASCII format
For programs compiled in Unicode :
Code: Select all
PokeS(*memory, source.s, -1, #PB_Ascii) ;would convert a string from the default format of Unicode to an ASCII string located at *memory
destination.s=PeekS(*memory, -1, #PB_Ascii) ;would convert a string at *memory from Ascii to the default Unicode format
Tipperton wrote:pdwyer wrote:Generally a conversion requires you to actually convert one type to another, not just look at a pointer in a different way.
Agree a real conversion would have you specify both the source and destination formats. Here it seems that for native strings you are restricted to what you configure the project for via the compiler settings.
A real conversion is performed and both the source and destination formats are always specified. For PokeS the soruce format is the compiled format (i.e. Ascii or Unicode), while the destination is specified by flags (i.e. #PB_Unicode). For PeekS the source format is specified by flags, while the destination format is the compiled format. So to review, one format can be specified by a flag while one or both formats are specified by the compile format (Ascii or Unicode).
The problem is really not conversion but accessing the string in it's current format regardless of the mode the program was compiled in.
Tipperton wrote:Code: Select all
asciistring.s ; this is an ASCII string
unicodestring.u ; this is a Unicode string
I think this would be the way to go. Likewise a char type for each would also be needed. Because of the current format of variable types I run out of sensible types when only single letters are used. I think going to a two letter format would be better. Something like:
Code: Select all
anychar.c ;1 or 2 bytes depending if compile format is Ascii or unicode
asciichar.c1 ;1 byte unsigned value for characters or byte
unicodechar.c2 ;2 byte unsigned value for characters or word
;and while we're at it throw in some of these to round out the possibilities for non string variables
unsignedlong.c4 ;4 byte unsigned for long
unsignedquad.c8 ;8 byte unsigned for quad
*Edit:removed a leftover '@' from a quote (I corrected one, not the other), change the suggested feature to remove float types.