----------------------
using System;
using System.Text;
namespace CatKing
{
class StrigTester
{
static public void Main()
{
string str = "猫王 is not a cat.";
Console.WriteLine("{0}の文字列長は{1}",str, str.Length);
Console.WriteLine("{0}はShift_JISでは{1}byte.",
str,
Encoding.GetEncoding("Shift_JIS").GetByteCount(str));
}
}
}
-------------
実行結果
猫王 is not a cat.の文字列長は16
猫王 is not a cat.はShift_JISでは18byte.