Is it possible that data conversion will convert binary data to Windows-1252 encoding?

I understand that the best way to convert binary data to text format is to use base64 encoding. UTF-8 may cause loss. But as I studied this, I found that the encoding of Windows-1252 does not seem to result in data loss through its design.

I provide a lot more context on my blog here .

In the end, I will give a few reasons why I still will not store binary data as a Windows-1252 string. But I'm curious if there is a data loss scenario that I have not considered.

+4
source share
2 answers

You should not put binary data in a string, because binary data can contain bytes with values ​​below 32. This has nothing to do with the encoding of the string.

And I'm not sure where you got "UTF-8 is a loss, but CP1252 is not." But I'm not sure I want to know.

0
source

Actually, the problem is better understood if you think that you are not converting binary data to CP1252 , and in C# you are converting binary data like CP1252 to UTF-16 , so the question would be CP1252 β†’ UTF-16 β†’ CP1252 guarantee the absence of polymorphic mutations.

The .net text encoder is best suited for UTF-16 β†’ CP1252 , which sounds best, although it can test well, scenarios in which you can’t do anything with UTF-16 in the middle of the line, which still does not guarantee data loss, and it is much less efficient than an array of bytes.

0
source

Source: https://habr.com/ru/post/1393711/


All Articles