Solved

Tips for handling special characters within scripts...???

Posted on 2006-10-20
2
314 Views
Last Modified: 2008-02-01
I often find myself having to deal with special characters causing errors in my scripts.  Usually it's where SQL is involved because an apostrphy is included in the value that's getting used in the SQL statement which causes a parsing error.  I fix this in these instances by using something similar to:

var = Replace(var, "'", "''")

So that works for small things like a name field, or an address field, and for SQL with apostrophy's.  But here's an instance where I'm actually saving an XML response to disk like this:

set fs = CreateObject("Scripting.FilesystemObject")
filename = Server.MapPath("../xml/eBay/GetItemResponse_"&eBayItemID&".xml")
set tfile=fs.CreateTextFile(filename, true)
tfile.WriteLine(xmlResponse)
tfile.Close
set tfile = nothing
set fs = nothing

This works 98% of the time, however, I came across an order today where the address included in the response was the following:

Ulrich Braun
Enzianstraße 34
Waldkraiburg,   84478
Germany

Upong trying to save the file to disk I get an error:

Microsoft VBScript runtime error '800a0005'

Invalid procedure call or argument

I don't think the same fix would work on this because that's an entire XML response.  Replacing all single ' with double '' will just break something else most likely.

Is there any particular way to easily handle these types of things in vbscript so that I don't have to constantly find work-arounds for them?  any info would be great.  thanks!
0
Comment
Question by:Andrew Angell
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 11

Author Comment

by:Andrew Angell
ID: 17777315
the space between the e and 34 in the address actually contained a Square in the response.  i don't even know how to make a square.
0
 
LVL 58

Accepted Solution

by:
amit_g earned 500 total points
ID: 17777646
You should use unicode if your XML can have that. Change CreateTextFile(filename, true) to

set tfile=fs.CreateTextFile(filename, true, true)
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
File download script VBSCRIPT fail on download PPT files 2 77
JQuery to parse xml string and get element by id 4 73
Designing forms 3 70
Validating Date 4 38
I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…

734 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