Internationalization and localization tools


Culture-Sensitive C# Constructor

using System.Text

public UTF7Encoding();

public UTF7Encoding(bool allowOptionals);

Internationalization (I18n) Class Overview

This class encodes Unicode characters using UCS Transformation Format, 7-bit form (UTF-7). This encoding supports all Unicode character values. Surrogate pairs are encoded as two separate surrogate code points.

UTF-7 encoding was originally invented to efficiently transmit Unicode characters through email systems optimized for US-ASCII text messages.

For more information see Microsoft's MSDN online documentation. Also, see specific MSDN documentation on Encoding Properties.

I18n Issues

Use of this class probably does not pose an I18n problem. Globalyzer detects it by default because during the internationalization process it is important that you are aware of all of the places in your code where you are performing character encoding conversions. Further, UTF-7 is different from the form of Unicode used by C# internally (UTF-16, a two-byte Unicode encoding).

UTF-7 encodes Unicode characters with a variable number of bytes per character. This encoding is optimized for the lower 127 ASCII characters, yielding an efficient mechanism to encode English in an international way.

If, once you have examined a particular instantiation of the UTF7Encoding class, you determine that it does not pose I18n problems, you can use Globalyzer's Ignore Comment functionality to ensure that it isn't picked up in a subsequent scan.

Usage Example

String unicodeString =
   "This Unicode string contains two characters " +
   "with codes outside a 7-bit code range, " +
   "Pi (\u03a0) and Sigma (\u03a3).";
// Encode the string.
Byte[] encodedBytes = utf7.GetBytes(unicodeString);
Console.WriteLine();
Console.WriteLine("Encoded bytes:");

C# Encoding Information

 

Lingoport internationalization and localization services and software