DefineEncoding Text Data Type

I think I’m miss understanding what DefineEncoding should do

I’m getting some data from a UDP Socket and I define it as WindowsANSI

[code]Dim dataLocal As Text = data.DefineEncoding(Encodings.WindowsANSI).ToText

If I do Encoding(dataLocal).internetName it return UTF-8[/code]

If I do

[code]Dim dataLocal As String = data.DefineEncoding(Encodings.WindowsANSI)

If I do Encoding(dataLocal).internetName it return windows-1252[/code]

Is this normal behaviour and Text Type returns UTF-8?

I suspect your Text variable is auto converting to string when passed to Encoding. A Text doesn’t contain a specific encoding. It contains codepoints.

See this discussion for some context and background:

https://forum.xojo.com/22534-string-vs-text-an-explanation