Search code examples
vb.netunicodeglobalization

Asc(Chr(254)) returns 116 in .Net 1.1 when language is Hungarian


I set the culture to Hungarian language, and Chr() seems to be broken.

System.Threading.Thread.CurrentThread.CurrentCulture = "hu-US"
System.Threading.Thread.CurrentThread.CurrentUICulture = "hu-US"

Chr(254) 

This returns "ţ" when it should be "þ"

However, Asc("ţ") returns 116.

This: Asc(Chr(254)) returns 116.

Why would Asc() and Chr() be different?

I checked and the 'wide' functions do work correctly: ascw(chrw(254)) = 254


Solution

  • My best guess is that your Windows tries to represent Chr(254)="ţ" as a combined letter, where the first letter is Chr(116)="t" and the second ("¸" or something like that) cannot be returned because Chr() only returns one letter.

    Unicode text should not be handled character-by-character.