Xojo.Net.HttpSocket and Encoding

In the PageReceived of Xojo.Net.HttpSocket, I need to parse the result data.

For this, I want to convert the Memoryblock to Text or String.

The documentation and all examples say that this is the way to do it:

Dim tResult As Text Try tResult = Xojo.Core.TextEncoding.UTF8.ConvertDataToText(Content) Catch End Try
This works fine if the data is indeed UTF8. But what if the response headers say (for example): text/html; charset=CP1256

With the above, it fails with: The data could not be converted to text with this encoding.

How do I handle this correctly?
Or is there a way to convert the Memoryblock to Text/String and then do DefineEncoding/ConvertEncoding after I figured out what it should be?

pick the right encoding object baed on the header and use the encoding you need.

xojo.core.TextEncoding.Windows1252 for example.

this is better

dim t as xojo.core.TextEncoding = xojo.core.TextEncoding.FromIANAName("CP1256")

Nice. That will work.
Thank you!