Wednesday, 18 September 2013

Why does not recommend Default encoding in C#?

Why does not recommend Default encoding in C#?

I Googled about encoding. I found that Default encoding is not recommended
in C#. Full message is:
Different computers can use different encodings as the default, and the
default encoding can even change on a single computer. Therefore, data
streamed from one computer to another or even retrieved at different times
on the same computer might be translated incorrectly. In addition, the
encoding returned by the Default property uses best-fit fallback to map
unsupported characters to characters supported by the code page. For these
two reasons, using the default encoding is generally not recommended. To
ensure that encoded bytes are decoded properly, your application should
use a Unicode encoding, such as UTF8Encoding or UnicodeEncoding, with a
preamble. Another option is to use a higher-level protocol to ensure that
the same format is used for encoding and decoding.
Source MSDN
But how to change decoding of Computer ? I am not clear about the bit
"Different computers can use different encodings as the default".

No comments:

Post a Comment