UTF-16 .ToText is broken

I wouldn’t normally do this, but I think this one is kind of important. String.ToText is broken when the string is encoded as UTF-16. Try this:

dim s as string = "hello"
s = s.ConvertEncoding( Encodings.UTF16 )
dim t as text = s.ToText
// t = "?????"

See <https://xojo.com/issue/39356>.

Also try

  dim s as string = "hello"
  s = s.ConvertEncoding( Encodings.UTF16 )
  dim t as text = s.ToText
  
  s = "hello"
  s = s.ConvertEncoding( Encodings.UTF16BE )
  t = s.ToText
  
  s = "hello"
  s = s.ConvertEncoding( Encodings.UTF16LE )
  t = s.ToText
  
  break

I think the issue here is that UTF16 doesn’t imply BE or LE without a BOM and failing that its assumed to be one way or the other

Yes, BE and LE work. We agree this is a bug and it should work as written, yes?

BTW, UTF-32 is entirely broken, but I doubt anyone would notice.

I have :(.

Now that I’ve called attention, please move this thread to General. Thanks.