Well, I am still confused..
Lets say I want a é character.
In this browser I do Alt+130 (numpath).
Issue 1:
In Studio, Alt+130 gives a music note.
Issue 2:
When I copy a é from the web, into a (utf-8) DataFlex Source file, and then do a (Ascii(sChar)) I get 233.
On the web I found that this character can be:
UTF-8: 0xC3 0xA9 or dec bytes 195 169 or combined 50089
UTF-16BE: 0x00E9 or dec bytes 0 233 or combined 233
UTF-16LE: 0xE900 or dec bytes 233 0 or combined 59648
ANSI: 233
OEM: 130
With Diacritic: e (U+0065) - ◌́ (U+0301)
Alt code: Alt 130
The ASCII function returns 233 so this is either the ANSI code or the UTF-16BE, I was expecting 50089, the Utf-8 decimal value.
When moving string to UChar I do get 195, 169 (Utf-8)
When moving wstring to Uchar I get 233, 0 (Utf-16 LE)
So we have three 'standards'
Utf-8 = String
Utf-16BE = Character and Ascii functions
Utf-16LE - WString
I think this is a bit much, and agree with the original statement, that the Character and Ascii functions should be based on the Utf-8 decimal value of 50089.
Copy attached in a source file and compile, with a breakpoint on the inkey, inspecting the locals.
Code:
Use Windows.pkg
Procedure CharTest
String sChar
String sChar2
WString sWchar
UChar[] ucString
UChar[] ucWString
Integer iAscii
// C3 = 195 a9=169
// Should have been able to do Alt+130 but that showed a music note, had to copy from https://unicode-table.com/en/00E9/
Move "é" to sChar
Move (Ascii(sChar)) to iAscii
// I am surprised to see that this is value 233 the decimal value of the UTF-18BE 00e9
// I was expecting 50089, the decimal of UTF-8 c3A9
Move sChar to sWchar
Move (StringToUCharArray(sChar)) to ucString
// Shows 195, 169 the correct UTF-8 codes
Move (WStringToUCharArray(sWchar)) to ucWString
// Shows 233, 0 the correct bytes for UTF-16LE, this is unexpected
// I expected 0, 233 the UTF-16BE as that is how the Ascii function works...
Move (Character(iAscii)) to sChar2
Inkey windowindex
End_Procedure
Send CharTest
ps this is the released DataFlex 2021, version 20.0
Kind regards
Marco