Solved

VBScript Asc function not returning correct ASCII code for accented characters

Posted on 2013-07-01
2
1,192 Views
Last Modified: 2013-07-01
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?
0
Comment
Question by:mike99c
2 Comments
 
LVL 42

Accepted Solution

by:
sedgwick earned 500 total points
ID: 39289737
try AscW() instead of Asc()
0
 

Author Comment

by:mike99c
ID: 39289761
That did the trick, thanks a lot, I had never come across this function before.
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Hello again, all.  For those of you that have been following along, you'll know that this is my third article on this topic (though it is not Part III).  This article is sort of remedial, and probably the topic with which I should have started the s…
This is pretty cool.  The purpose of this VB Script is to help you document where JAR (Java ARchive) files and specifically java class files are located so that you can address issues seen with a client or that you can speak intelligently with a dev…
This video discusses moving either the default database or any database to a new volume.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now