(I left some code in my first post which minus 48 from the value. Don't worry about that part, and refer to the below on what I am trying to do).
I will see if I can help understand it a little better..
Maybe this strange code isn't required, but not sure how to do it so I gave it a go.
Basically I am wanting to convert the Character to a Decimal Value.
You are correct in saying D is 68.
Š should be 138 as another example.
I am trying get the decimal value (138) from the Character (Š) as an example.
I have now put all my code in one function and hopefully helps understand what I am trying to do..
Log(GetDecimal_From_Character("D")) ' returns 68 which is correct
Log(GetDecimal_From_Character("Z")) ' returns 90 which is correct
Log(GetDecimal_From_Character("x")) ' returns 120 which is correct
Log(GetDecimal_From_Character("Š")) ' returns 63 but should have returned 138
Log(GetDecimal_From_Character("€")) ' returns 63 but should have returned 128
Sub GetDecimal_From_Character(Character As String) As Int
Dim HexStr As String
Dim bc As ByteConverter
HexStr = bc.HexFromBytes(Character.GetBytes("ISO-8859-1"))
Dim Lng As Long
Dim Digit As String
Dim DigitVal As Int
For i = HexStr.Length -1 To 0 Step -1
Digit = HexStr.SubString2(i, i+1).ToUpperCase
If Not("0123456789ABCDEF".Contains(Digit)) Then
' not valid char
Return 0
End If
If Digit.CompareTo("9") > 0 Then
DigitVal = Asc(Digit) - 55
Else
DigitVal = Digit
End If
Lng = Lng + DigitVal * Power(16, HexStr.Length - 1 - i)
Next
Return Lng ' return the Decimal Value
End Sub