VbScript/ASP and encoding help needed

VbScript/ASP and encoding help needed

am 12.04.2006 20:49:14 von Kansasfiddler

Hi and thanks for reading this!

I am receiving an xml file via an ASP page using the serverXmlHttp
object. There is a french character that reads which I need to
be able to replace with é. I am at a loss for how to do this using
ASP or VBScript.

I have tried the Replace() function to no avail.

I am using ASP 3.0 in IIS5 on Windows 2000 Advanced Server.

Do you know a way to make this change?

Thank you for your assistance!

Rich

Re: VbScript/ASP and encoding help needed

am 13.04.2006 11:44:36 von Anthony Jones

"Kansasfiddler" wrote in message
news:1144867754.259283.142090@e56g2000cwe.googlegroups.com.. .
> Hi and thanks for reading this!
>
> I am receiving an xml file via an ASP page using the serverXmlHttp
> object. There is a french character that reads which I need to
> be able to replace with é. I am at a loss for how to do this using
> ASP or VBScript.
>

c3A9 is the UTF-8 encoding for é.

> I have tried the Replace() function to no avail.
>

Replace on what string. As soon as you have extracted the XML string from
ResponseText or from ResponseXML.XML you will have a unicode string and
the character will be repesented as 0xE900 or 233 in decimal. Hence your
find what it thinks it's looking for.

Why do feel you need to replace it anyway?

> I am using ASP 3.0 in IIS5 on Windows 2000 Advanced Server.
>
> Do you know a way to make this change?
>
> Thank you for your assistance!
>
> Rich
>

Re: VbScript/ASP and encoding help needed

am 13.04.2006 14:16:26 von Kansasfiddler

Thanks for your response.

The document is delivered to me from a remote server and must not
change in any way while on my servers. It is part of a legal agreement.
When I return the document to the source server I am told that it has
changed because of the . The remote process then halts
execution and I am unable to proceed.
Ideally I would be able to preserve the entire document in it's
original encoding but the creators of this document tell me I can
"simply" replace the offending values with the é value and their
process will accept the document. Unfortunately I'm not familiar with
this level of manipulation and am wondering if it is even possible to
do in ASP/vbScript, though the producers of the document say that it
is. Any ideas on how to accomplish this will end days of frustration!


Thank you,

Rich

Re: VbScript/ASP and encoding help needed

am 13.04.2006 16:42:16 von Anthony Jones

"Kansasfiddler" wrote in message
news:1144930586.069005.298960@j33g2000cwa.googlegroups.com.. .
> Thanks for your response.
>
> The document is delivered to me from a remote server and must not
> change in any way while on my servers. It is part of a legal agreement.
> When I return the document to the source server I am told that it has
> changed because of the . The remote process then halts
> execution and I am unable to proceed.
> Ideally I would be able to preserve the entire document in it's
> original encoding but the creators of this document tell me I can
> "simply" replace the offending values with the é value and their
> process will accept the document. Unfortunately I'm not familiar with
> this level of manipulation and am wondering if it is even possible to
> do in ASP/vbScript, though the producers of the document say that it
> is. Any ideas on how to accomplish this will end days of frustration!
>
>

str = Replace(str, Chr(233),"é")

Why are you sending back a document that hasn't changed? What's the point?

Is it XML or are you using ResponseText?

How do you send the document back?

What encoding is being used to send it to you?
(Use ServerXMLHTTP's getResponseHeader("Content-Type") header what value
is it)




> Thank you,
>
> Rich
>

Re: VbScript/ASP and encoding help needed

am 13.04.2006 20:32:10 von Kansasfiddler

Thanks for your Reply.

By using getResponseHeader("content-Type") I was able to see that the
xml doc being sent to me is "application/xml".

I tried the str = Replace(str, Chr(233),"é") you suggested but the
doc is still being refused.

When I receive the initial document I use:
ServerXMLHttp.responseXML.xml and put it into a variable.
I then create a Msxml2.DOMDocument and use the loadXML method to load
up the document I've saved in a variable. I've also tried by loading
directly from the responseXML.

I then use the selectSingleNode method to grab the License Text node
value and nodeTypedValue to display it to my viewer AND to store it to
a text file on an NTFS partition. I have also tried to store it in a
SQL Server 2000 table.

To send it back I read the contents of the text file into a local
variable and add it to an xml document I build by appending the xml
tags and their contents to a variable called AccessLicenseRequest.

I then create an Msxml2.ServerXMLHttp object for the transport and use
setRequestHeader for content-tye and content-length
I create an Msxml2.DOMDocument and then use the
LoadXML(AccessLicenseRequest).
I begin my xml creation with as i am not allowed
to put more than that. No DOCTYPE is allowed.

I've done all of the above with and without the following:
Session.CodePage = 65001
Response.Charset = "ISO-8859-1"
<%@CODEPAGE = 65001%>

I'm not sure what the point in returning the document unchanged except
that it is a legal agreement between my user and the company. The
company is probably paranoid that if the user changes the wording of
the agreement and returns that then they will be help accountable for
acepting the changed agreement. I'd love it if they could lower their
intenisty from super fussy to something less restrictive but I don't
think that's gonna happen.

In the company's documentation the say they support the UTF-8 and
ISO-8859-1 character sets.

Re: VbScript/ASP and encoding help needed

am 14.04.2006 00:21:11 von Anthony Jones

"Kansasfiddler" wrote in message
news:1144953130.381488.304860@g10g2000cwb.googlegroups.com.. .
> Thanks for your Reply.
>
> By using getResponseHeader("content-Type") I was able to see that the
> xml doc being sent to me is "application/xml".
>
> I tried the str = Replace(str, Chr(233),"é") you suggested but the
> doc is still being refused.
>
> When I receive the initial document I use:
> ServerXMLHttp.responseXML.xml and put it into a variable.
> I then create a Msxml2.DOMDocument and use the loadXML method to load
> up the document I've saved in a variable. I've also tried by loading
> directly from the responseXML.
>
> I then use the selectSingleNode method to grab the License Text node
> value and nodeTypedValue to display it to my viewer AND to store it to
> a text file on an NTFS partition. I have also tried to store it in a
> SQL Server 2000 table.
>
> To send it back I read the contents of the text file into a local
> variable and add it to an xml document I build by appending the xml
> tags and their contents to a variable called AccessLicenseRequest.
>
> I then create an Msxml2.ServerXMLHttp object for the transport and use
> setRequestHeader for content-tye and content-length
> I create an Msxml2.DOMDocument and then use the
> LoadXML(AccessLicenseRequest).
> I begin my xml creation with as i am not allowed
> to put more than that. No DOCTYPE is allowed.
>
> I've done all of the above with and without the following:
> Session.CodePage = 65001
> Response.Charset = "ISO-8859-1"
> <%@CODEPAGE = 65001%>
>
None of the above are going to help. You will be using the data parameter
of the send method to send the data. What are you passing to this method.
A string or the DOM you've just created.

> I'm not sure what the point in returning the document unchanged except
> that it is a legal agreement between my user and the company. The
> company is probably paranoid that if the user changes the wording of
> the agreement and returns that then they will be help accountable for
> acepting the changed agreement. I'd love it if they could lower their
> intenisty from super fussy to something less restrictive but I don't
> think that's gonna happen.
>
> In the company's documentation the say they support the UTF-8 and
> ISO-8859-1 character sets.
>

Re: VbScript/ASP and encoding help needed

am 14.04.2006 05:05:28 von Kansasfiddler

Hi,
When I send I am sending a string.
Rich

Re: VbScript/ASP and encoding help needed

am 14.04.2006 15:21:18 von Kansasfiddler

Kansasfiddler wrote:
> Hi,
> When I send I am sending a string.
> Rich

I looked at the code I'm using when i got to work and I'm putting the
xml doc as a string into a DOM Document like this when sending:

Set sendDoc = Server.CreateObject("MSXML2.DOMDocument.3.0")
sendDoc.loadXML(AccessLicenseRequest)
HTTPObj.send (sendDoc)

Thanks,
Rich

Re: VbScript/ASP and encoding help needed

am 14.04.2006 21:12:28 von Kansasfiddler

I'm saving the string to the disc as a file with a .xml extension. I am
loading that up via the load method.
It is now being seen as an xml file.
However the french characters are now causing the xml to be malformed.
I am setting the content-type to application/xml as suggested by the
documents producers.
I have attempted to replace the characters with é and it still
bombs.
I'm using <%@ CODEPAGE=65001%> at the top of the pages where I am
sending the XML and also Response.CharSet = "utf-8" which has not
solved the problem.

I'm still stumped as to how i can prevent these french characters from
messing up the xml.

Thanks,
Rich

Re: VbScript/ASP and encoding help needed

am 17.04.2006 13:01:54 von Kansasfiddler

Has this message been dropped?

Can somene suggest another method I might use to retrieve XML, store it
and return it to the server without altering the encoding?

Thank you,
RIch

Kansasfiddler wrote:
> I'm saving the string to the disc as a file with a .xml extension. I am
> loading that up via the load method.
> It is now being seen as an xml file.
> However the french characters are now causing the xml to be malformed.
> I am setting the content-type to application/xml as suggested by the
> documents producers.
> I have attempted to replace the characters with é and it still
> bombs.
> I'm using <%@ CODEPAGE=65001%> at the top of the pages where I am
> sending the XML and also Response.CharSet = "utf-8" which has not
> solved the problem.
>
> I'm still stumped as to how i can prevent these french characters from
> messing up the xml.
>
> Thanks,
> Rich

Re: VbScript/ASP and encoding help needed

am 17.04.2006 18:49:12 von Anthony Jones

"Kansasfiddler" wrote in message
news:1145271714.318414.214090@g10g2000cwb.googlegroups.com.. .
> Has this message been dropped?
>
> Can somene suggest another method I might use to retrieve XML, store it
> and return it to the server without altering the encoding?
>
> Thank you,
> RIch
>
> Kansasfiddler wrote:
> > I'm saving the string to the disc as a file with a .xml extension. I am
> > loading that up via the load method.
> > It is now being seen as an xml file.
> > However the french characters are now causing the xml to be malformed.
> > I am setting the content-type to application/xml as suggested by the
> > documents producers.
> > I have attempted to replace the characters with é and it still
> > bombs.
> > I'm using <%@ CODEPAGE=65001%> at the top of the pages where I am
> > sending the XML and also Response.CharSet = "utf-8" which has not
> > solved the problem.
> >
> > I'm still stumped as to how i can prevent these french characters from
> > messing up the xml.
> >
> > Thanks,
> > Rich

It hasn't been dropped I'm just have a little difficulty putting together
what it is your actually doing. Here is my best guess at what you end up
doing and why it doesn't work.

First you are sending the XML back to the server with ServerXMLHTTP object.

You are setting the Session.Codepage to 65001 and the Response.CharSet to
UTF-8. Both of these are pointless since they have no effect on the
ServerXMLHTTP object.

You are loading the Original XML into a string from a file. (I'm not quite
sure why you can't just use the XML DOMs save and load methods for this part
of the operation.)

You are then attempting to replace this é character with é. Hence you
end up with a a string part of which contains this escape sequence. Given
that this string is being held in a variable called AccessLicenseRequest you
then do the following.

Set sendDoc = Server.CreateObject("MSXML2.DOMDocument.3.0")
sendDoc.loadXML(AccessLicenseRequest)
HTTPObj.send (sendDoc)

The reason why this doesn't work is that the é will be parsed out as
soon as it is loaded into the DOM and by default passing an XML DOM to the
xmlhttp send method causes the output to be encoded as UTF-8.

My suggestion for a fix is this. First try this:-

When you have received the XML try simply storing it to disk using the Save
method of the XML DOM. The XML file will be saved using the same encoding
used to send it.

Not the above code becomes:-

Set sendDoc = Server.CreateObject("MSXML2.DOMDocument.3.0")
sendDoc.load strFilePath
HTTPObj.send sendDoc

ServerXMLHTTP will use the same encoding found in the document to send it.

I suspect the original document is coming down as ISO-8859-1. This approach
preserves that encoding.

Anthony.

Re: VbScript/ASP and encoding help needed

am 17.04.2006 19:46:36 von Kansasfiddler

Thanks for your reply. i managed to get somethig to work. I used
Response.charset = "ISO-8859-1" at the top of both my receiving and
sending page. When I changed this to utf-8 the french character showed
up as a chinese character :)
I also added the encoding type to the xml document header just to be
safe.

I then used the load method of a DOMDocument 4.0 object to load up the
xml I had saved to disc, set the content-Type header to
"application/x-www-form-urlencoded" and sent the dom object via the
send method of the serverxmlhttp object. I finally got back a
successful response for the first time in over a month.
I plan on sending UPS support the method for gaining success since they
weren't able to figure it out either.

If anyone reads this and is having similar issues with UPS on the
microsoft platform send email to kayaker411@aol.com and I'll try to
help you out.

Thanks!
Rich