Originally posted by Mike Doty
View Post
If you knew that the byte string was actually UTF8 encoded text, you would need to convert it to WSTRING using
myWideString = UTF8ToCHR$(sBuffer).
If you knew that it was UTF16 encoded text, you would have to use:
IF nBytes THEN myWideString = PEEK$$(VARPTR(vByteArray(0)), nBytes/2)
But since there is no indication what ResponseBody actually contains, how would you know which to do?
You are either going to get spurious charactes such as CHRS(193) i.e. &HC1 or "Á" in UTF8 oro truncated test with the first Null in UTF16.
Bottom line:
Parsing ResponseBody for an HTML page is an ugly kludge for a poorly structured page .
Try plugging http://www.garybeene.com/power/code/gbsnippets0052.htm into https://validator.w3.org/
Initially it won't validate at all because it thinks it is UTF8 in accordance with the Server Response.
"Sorry, I am unable to validate this document because on line 1 it contained one or more bytes that I cannot interpret as utf-8 (in other words, the bytes found are not valid values in the specified Character Encoding). Please check both the content of the file and the character encoding indication."
Change the "encoding" manually to WIndows-1252 or ISO 8859-1
and note the 362 Warnings and Errors identified on the page

(If you tell it to validate as HTML2.0, you only get 136 errors

Comment