Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 230161
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T19:49:34+00:00 2026-05-11T19:49:34+00:00

I have a problem with classc ASP / VBScript trying to read an UTF-8

  • 0

I have a problem with classc ASP / VBScript trying to read an UTF-8 encoded XML file with MSXML. The file is encoded correctly, I can see that with all other tools.

Constructed XML example:

<?xml version="1.0" encoding="UTF-8"?>
<itshop>
    <Product Name="Backup gewünscht" />
</itshop>

If I try to do this in ASP…

Set fso = Server.CreateObject("Scripting.FileSystemObject")
Set ts = fso.OpenTextFile("input.xml", FOR_READING)
XML = ts.ReadAll
ts.Close
Set ts = nothing
Set fso = Nothing

Set myXML = Server.CreateObject("Msxml2.DOMDocument.4.0")
myXML.loadXML(XML)
Set DocElement = myXML.documentElement
Set ProductNodes = DocElement.selectNodes("//Product")
Response.Write ProductNodes(0).getAttribute("Name")
' ...

… and Name contains special characters (german umlauts to be specific) the bytes of the umlaut “two-byte-code” get reencoded, so I end up with two totally crappy nonsense characters. What should be “ü” becomes “ü” – being FOUR bytes in my output, not two (correct UTF-8) or one (ISO-8859-#).

What am I doing wrong? Why is MSXML thinking that the input is ISO-8859-# so that it tries to convert it to UTF-8?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T19:49:34+00:00Added an answer on May 11, 2026 at 7:49 pm
    Set ts = fso.OpenTextFile("input.xml", FOR_READING, False, True)
    

    The last parameter is the “Unicode” flag.

    OpenTextFile() has the following signature:

    object.OpenTextFile(filename[, iomode[, create[, format]]])
    

    where “format” is defined as

    Optional. One of three Tristate values used to indicate the format of
    the opened file. If omitted, the file
    is opened as ASCII.

    And Tristate is defined as:

    TristateUseDefault  -2   Opens the file using the system default.
    TristateTrue        -1   Opens the file as Unicode.
    TristateFalse        0   Opens the file as ASCII.
    

    And -1 happens to be the numerical value of True.

    Anyway, better is:

    Set myXML = Server.CreateObject("Msxml2.DOMDocument.4.0")
    myXML.load("input.xml")
    

    Why should you use a TextStream object to read in a file that MSXML can read perfectly on it’s own.

    The TextStream object also has no notion of the actual file encoding. The docs say “Unicode”, but there is more than one way of encoding Unicode. The load() method of the MSXML object will be able to deal with all of them.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 166k
  • Answers 166k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Raphyboy, Content Deployment is a MOSS-only feature; it is not… May 12, 2026 at 1:19 pm
  • Editorial Team
    Editorial Team added an answer you need to add AND file_logs.user_id = published_file_ratings.author_id to your… May 12, 2026 at 1:19 pm
  • Editorial Team
    Editorial Team added an answer Further to my comment to bastianneu, I've spent about 10… May 12, 2026 at 1:19 pm

Related Questions

I have a very tricky problem going on with content inside a textarea on
I've begun using ASPUnit to unit test my classic ASP code. This is all
I've created an IHttpHandler in .NET C# which returns pieces of html to a
I think I have the same problem as kcrumley describes in the question Problem

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.