View Single Post
  #6 (permalink)  
Old March 8th, 2009, 03:07 PM
Old Pedant Old Pedant is offline
Friend of Wrox
 
Join Date: Jun 2008
Location: Snohomish, WA, USA
Posts: 1,649
Thanks: 3
Thanked 141 Times in 140 Posts
Default

He posted this in www.aspmessageboard.com, as well, and uploaded the actual file there.

From my remarks in that forum:

*********

Yep, exactly as predicted. It is a UNICODE FILE!

All you had to do was open it in NOTEPAD and then do SAVE AS... and Notepad would have shown you that it was going to save it as Unicode by default. Meaning that it *is* a Unicode file to start with.

Now go read the docs on Scripting.FileSystemObject.OpenTextFile:
http://msdn.microsoft.com/en-us/libr...4s(VS.85).aspx

See what it says there?
Quote:
format
Optional. One of three Tristate values used to indicate the format of the opened file. If omitted, the file is opened as ASCII.
So now change your code to do
Code:
this_file = FileObj.OpenTextFile(Server.MapPath("mediaeasy.xml"),1,false,-1 );
Voila! It works.

Note that to write the text back OUT as Unicode you will need to read the docs for CreateTextFile (or use OpenTextFile and overwrite).
Reply With Quote