Quin wrote: Tue Jan 23, 2024 9:46 pm
infratec wrote: Tue Jan 23, 2024 8:14 pm
Strings inside PB are always Unicode
How is unicode different from UTF-8? I thought UTF-8 is the default for most unicode operations?
The name is a little bit misleading.
PureBasic can handle the basic multilingual plane (BMP) of the Unicode-Standard.
This characters are stored internally always as
UTF-16 (in PureBasic called #PB_Unicode). The full Unicode-Standard can be stored in UFT-32 or UTF-8, where the latter has a variable character-byte-length and is therefore not suitable for internal use, but for data transfer.
For example, if you use WriteString() the string is stored in UTF-8 encoding.
JSON itself is UTF-8 encoded, but at the moment you transfer it into PureBasic, it is encoded as UTF-16 internally.
You can use UTF8(JSON$) instead of @JSON$, to receive an allocated memory of a string in UTF-8 format.