How to read utf-8 xml from vbs and get correct character code

I am trying to read an xml file from a vbs script. Xml is encoded in utf-8 and has an appropriate header

From vbs script I am using microsoft xmldom parser to read xml:

Dim objXMLDoc
Set objXMLDoc = CreateObject( "Microsoft.XMLDOM" )
objXMLDoc.load("vbs_strings.xml")

      

Inside the xml I am trying to write a character by code using notation &#nnn;

. Then I read this symbol from vbscript and try to get its code using a function Asc()

. For some characters it works fine and the code read is equal to one written. But for some characters it Asc()

always returns a code 63

. What could it be?

Examples:

If the xml contains <section>&#195;<section>

and in the script, I have a variable Section

to represent that xml node, then the code is:

Asc(Section.Text)

      

will return 195 and that's it ok

.

If xml contains <section>&#110;<section>

then code:

Asc(Section.Text)

      

will return 110 and that's it ok

.

But if xml contains <section>&#130;<section>

either <section>&#156;<section>

or<section>&#140;<section>

Asc(Section.Text)

      

will return 63, which is definitely not good.

Do you know why?

+2


a source to share


2 answers


Decimal code points 130, 156, and 140 do not match any character in the Unicode character set (123-192 undefined). The default character mapper that uses Asc will display errors like this? which is character 63. What characters are these code points?



I suspect the required codes are: &#8218;

&#339;

and&#338;

+2


a source


Use AscW instead:

http://msdn.microsoft.com/en-us/library/zew1e4wc%28VS.80%29.aspx



EDIT: This suggests that AnthonyWJones is most likely correct, that your document is either using character references or has misread the input encoding.

+2


a source







All Articles