Why do you want the ASC code only for the 2nd byte/position ?
ASCII is meant to return the entire "character" codepoint.. in this case your "Ã", which is 195. (U00C3)
Look the following example:
Code:
// https://www.unicode.org/charts/case/chart_Latin.html
//
// Ế - 1EBE - 7870
// ế - 1EBF - 7871
// Ề - 1EC0 - 7872
// ề - 1EC1 - 7873
// Ể - 1EC2 - 7874
// ể - 1EC3 - 7875
// Ễ - 1EC4 - 7876
// ễ - 1EC5 - 7877
// Ệ - 1EC6 - 7878
// ệ - 1EC7 - 7879
Move "ẾếỀềỂểỄễỆệ" to sValue
For i from 1 to (Length(sValue))
Show ("sValue = " + Mid(sValue, 1, i ))
Showln (" | Ascii(sValue) = " + String(Ascii(Mid(sValue, 1, i ))))
Loop
will produce the expected unicode code-point for each "char"
Code:
sValue = Ế | Ascii(sValue) = 7870
sValue = ế | Ascii(sValue) = 7871
sValue = Ề | Ascii(sValue) = 7872
sValue = ề | Ascii(sValue) = 7873
sValue = Ể | Ascii(sValue) = 7874
sValue = ể | Ascii(sValue) = 7875
sValue = Ễ | Ascii(sValue) = 7876
sValue = ễ | Ascii(sValue) = 7877
sValue = Ệ | Ascii(sValue) = 7878
sValue = ệ | Ascii(sValue) = 7879
Now.. What I don't understand from your sample, is WHY your Mid(1,2) returned actually something.. as your string has only 1 single unicode "char". The 2nd position simply "should not exist"
Mid("Ã", 1, 2) should return nothing.. in my opinion. as Mid should not count on bytes position anymore..
- If {position} is greater than the length of {string-value}, the function will return an empty string.
And it does,, if I hardcoded that..
Code:
Showln ('Mid("Ã", 1, 2) = ' + Mid("Ã", 1, 2))
Showln ('Ascii(Mid("Ã", 1, 2)) = ' + String(AscII(Mid("Ã", 1, 2))))
Results in
Code:
Mid("Ã", 1, 2) =
Ascii(Mid("Ã", 1, 2)) = 0
As I expected.. Now why you are getting something, when you read it from the file... !?!? Something seems not right. Maybe because your file has no BOM, and its reading it as if it was an ANSI instead of utf-8 ?