Link to home
Start Free TrialLog in
Avatar of mike99c
mike99c

asked on

VBScript Asc function not returning correct ASCII code for accented characters

I am trying to convert some characters to ASCII code using the VBScript Asc function but the accented characters are giving incorrect negative values.

Take a look at this example:

	response.write "Ascii a (small a): " & Asc("a") & "<br />"
	response.write "Ascii á (small a with acute): " & Asc("á") & "<br />"
	response.write "Ascii ä (small a with diaeresis): " & Asc("ä") & "<br />"

Open in new window


The output is:

Ascii a (small a): 97
Ascii á (small a with acute): -15455
Ascii ä (small a with diaeresis): -15452

But I was expecting:

Ascii a (small a): 97
Ascii á (small a with acute): 225
Ascii ä (small a with diaeresis): 228

Am I missing something here and does the Asc function only work on non accented characters?
ASKER CERTIFIED SOLUTION
Avatar of Meir Rivkin
Meir Rivkin
Flag of Israel image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of mike99c
mike99c

ASKER

That did the trick, thanks a lot, I had never come across this function before.