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>Ã<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>n<section>
then code:
Asc(Section.Text)
will return 110 and that's it ok
.
But if xml contains <section>‚<section>
either <section>œ<section>
or<section>Œ<section>
Asc(Section.Text)
will return 63, which is definitely not good.
Do you know why?
a source to share
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: ‚
œ
andŒ
a source to share
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.
a source to share