Jens, I know about
let str = String(data: Data(yourWin1252ByteArray), encoding: .windowsCP1252)
But that works well as long as your input is really CP1252 but what happens if you hit bytes with hex values 0x81, 0x8D, 0x8F, 0x90, and 0x9D which are not defined? I tried
String (data:, encoding: .windowsCP1252) with 0x81 it returns
I took 1252 as an example, but I could have taken any of the other
String.Encoding corresponding values other than UTF8 and ASCII.
as: UTF16.self also fails, the compiler complaining about the size of the Data.Element (16 bits not 8 bits), but I'm not too sure why
String(decoding: , as: ) cannot be used with all
String.Encoding-like values replacing invalid byte values with a replacement character.