Solved

VBScript Asc function not returning correct ASCII code for accented characters

Posted on 2013-07-01
2
1,214 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 Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I met Paul Devereux (@pdevereux) today when I responded to his tweet asking “Anybody know how to automate adding files from disk to a folder in #outlook  ?”.  I replied back and told Paul that using automation, in this case scripting, to add files t…
With User Account Control (UAC) enabled in Windows 7, one needs to open an elevated Command Prompt in order to run scripts under administrative privileges. Although the elevated Command Prompt accomplishes the task, the question How to run as script…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

856 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