Characters § and £ are on 2 bytes?

I noticed by chance that the 2 characters § and £ are on 2 bytes ???
I thought there were both ASCII standard then 1 byte.
http://math.pc.vh.free.fr/info/ascii.htm
Run the following code :


Dim TampText as String

TampText = "£" ' TextField1.Text.left(1)
MessageBox str(TampText.Length) + " , " + str(TampText.Bytes)

TampText = "§" ' TextField1.Text.left(1)
MessageBox str(TampText.Length) + " , " + str(TampText.Bytes)

Result will be : “1 , 2”. Just to know if it is normal.

It’s not part of ASCII, but part of extended areas like ISO 8859-1.
In UTF-8, this is 2 bytes for the character.

1 Like
Var s As  String = "£§"
System.DebugLog s + " : " + s.Bytes.ToString // UTF-8

s = s.ConvertEncoding(Encodings.ISOLatin1)
System.DebugLog s + " : " + s.Bytes.ToString // ISO 8859-1

Output:

       £§ : 4
       £§ : 2
1 Like

String literals and TextField text are UTF8, not ASCII (or Latin1).

Ok thank you. As those 2 characters are common I thought they were in 1 byte even in UTF8.

The best web site to explore encoding is: The UniSearcher

1 Like

The only 1-byte chars in UTF-8 are those in the 0-127 range, same as un-extended ASCII.

1 Like