Calculates the maximum number of bytes produced by encoding the specified number of characters. : UTF8Encoding « Internationalization I18N « C# / C Sharp
Calculates the maximum number of bytes produced by encoding the specified number of characters.
using System; using System.Text;
class UTF8EncodingExample { public static void Main() {
UTF8Encoding utf8 = new UTF8Encoding(); int charCount = 2; int maxByteCount = utf8.GetMaxByteCount(charCount);
Console.WriteLine(maxByteCount);
}
}