Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

WinHTTP & CHARSET ISO-8859-1

1,113 views
Skip to first unread message

Charlie B

unread,
Oct 14, 2002, 6:01:09 AM10/14/02
to
Stephen,

I have recently found out that I must make and XML submission from winhttp
to tomcat and that the servlets will only support

LATIN-1 (ISO-8859-1). Is it possible to set the encoding from VB using
WinHTTP 5.1 ?

Cheers,

Charlie

Stephen Sulzer (Microsoft)

unread,
Oct 15, 2002, 1:35:42 AM10/15/02
to
Hi Charlie,

If you are POSTing a string using the WinHttpRequest object, you cannot
override how it encodes the string for transmission. The WinHttpRequest
object will always convert the Unicode string to UTF-8.

However, note that a Unicode string that contains only 7-bit
LATIN-1/ISO-8859-1 characters will remain unchanged when encoded as UTF-8
;-) In such cases, the WinHttpRequest object does not append a
"Charset=UTF-8" attribute to your Content-Type header. (And I would think
that the server would assume that the POST data is ISO-8859-1.)

So, if the XML text data that you are POSTing contains LATIN-1 alphanumeric
or punctuation character codes (each less than decimal 128), then all you
should have to do is specify the "ISO-8859-1" charset in your Content-Type
header:


WinHttpReq.SetRequestHeader "Content-Type", "application/xml;
Charset=ISO-8859-1"


However, if your POST data contains 8-bit characters, then you cannot supply
the data as a string to the Send method. In order to avoid the UTF-8
conversion, your application must convert the string into a byte array, and
supply that instead. The WinHttpRequest object will not attempt any data
conversion on a byte array.

Regards,

Stephen Sulzer
Microsoft Corporation


This posting is provided "AS IS" with no warranties, and confers no rights.

"Charlie B" <Pork...@neil.servebeer.com> wrote in message
news:ewsR#h2cCHA.2284@tkmsftngp10...

Charlie B

unread,
Oct 15, 2002, 8:10:56 AM10/15/02
to
Stephen,

Once again many thanx for the information.

Regards,

Charlie


0 new messages