unicodevb6winhttprequestwindows-1252

How the encoding/localization of a DLL error message is handled in a VB6 application?


(UPDATED: This question get updated after a better understanding of what's going on, I removed noisy wrong parts.)

This piece of code belongs to a COM DLL. For the context, it contains an ActiveX object which is created and handled inside a classic ASP Page.

Public Function getHttpResponse(url As String)
  Dim request As New WinHttpRequest
  
  On Error GoTo errGetHttpResponse
  request.Open "HEAD", url
  request.Send
  getHttpResponse = request.Status
  Exit Function
  
errGetHttpResponse:
  getHttpResponse = Err.Description
End Function

The Err.Description string localization and encoding seems to rely on the running environment. For an error 80072EE5, I get for Err.Description (retrieved from the GUI of an executable loading the DLL):

It is noticeable that the apostrophe isn't the same.

The ASP page calling and displaying the ActiveX output could be simplified like this:

Session.LCID=1036 ' French identifier (global.asa file)
Dim o : Set o = CreateObject("TheDLL.TheObject")
Response.Write o.getHttpResponse(anInvalidUrl)

While it renders correctly if run from Machine 1, from Machine 2 the apostrophe is hidden (source viewing on Firefox show a 00 92 square character). The generated HTML from Machine 2 is reproduced below:

00000000  4c 92 55 52 4c 20 6e 92  65 73 74 20 70 61 73 20  |L.URL n.est pas |
00000010  76 61 6c 69 64 65                                 |valide

The apostrophe became encoded as 0x92, which is RIGHT SINGLE QUOTATION MARK encoded in ISO-8859-1.

How is the difference explainable? And optionally is there a way to set the get this output platform-independent?

(And yes, this is a soon-to-die legacy code.)


Solution

  • After a extended discussion in the comment section with Remy Lebeau and GSerg, here are the keys to understand the differences: