Locale-Sensitive C# Constructor
using System.Text
public ASCIIEncoding();
Internationalization (I18n) Class Overview
The ASCIIEncoding class encodes Unicode
characters as single 7-bit ASCII characters.
This encoding only supports character values between U+0000 and U+007F.
See Microsoft's
MSDN online documentation for more information. Also, see specific MSDN documentation on
Encoding Properties here.
I18n Issues
ASCII as a character set is largely inadequate for internationalized applications
because it can be used to encode only English characters.
Consider using UTF8Encoding or
UnicodeEncoding instead. The Windows code page
that corresponds to ASCIIEncoding is 20127. This class inherits from the
Encoding class.
As a developer, you might have good reason to call the ASCIIEncoding
constructor; however Globalyzer will detect it anyway. If you have
determined that the call does not pose I18n problems, you can
uncheck the method in the Locale-Sensitive Method list so that Globalyzer will ignore it
during the next scan of your source code.
Suggested Replacement
UTF8Encoding();
Instead of:
ASCIIEncoding ascii = new ASCIIEncoding();
//The following character array contains a surrogate pair
//that can't be converted to ASCII
Char[] chars = new Char[] {'a', 'b', 'c',
'\uD869', '\uDED6', 'd'};
Byte[] bytes = ascii.GetBytes(chars);
Use:
UTF8Encoding utf8 = new UTF8Encoding();
Char[] chars = new Char[] {'a', 'b', 'c',
'\uD869', '\uDED6', 'd'};
Byte[] bytes = utf8.GetBytes(chars);
C# Encoding Information
|