CultureInfoクラスは、数字を東アラビア語( "٠"、 "١"、 "٢"、 "٣"、 "٤"、 "٥"、 "٦"、 "٧"、 "٨"、 "٩")または西アラビア語( "0"、 "1"、 "2"、 "3"、 "4"、 "5"、 "6"、 "7"、 "8"、 " 9 ")。あなたはそれを手動で変換しなければなりません、これはあなたのためにきちんとそれをする小さな関数です:
public string ConvertToEasternArabicNumerals(string input)
{
System.Text.UTF8Encoding utf8Encoder = new UTF8Encoding();
System.Text.Decoder utf8Decoder = utf8Encoder.GetDecoder();
System.Text.StringBuilder convertedChars = new System.Text.StringBuilder();
char[] convertedChar = new char[1];
byte[] bytes = new byte[] { 217, 160 };
char[] inputCharArray = input.ToCharArray();
foreach (char c in inputCharArray)
{
if (char.IsDigit(c))
{
bytes[1] = Convert.ToByte(160 + char.GetNumericValue(c));
utf8Decoder.GetChars(bytes, 0, 2, convertedChar, 0);
convertedChars.Append(convertedChar[0]);
}
else
{
convertedChars.Append(c);
}
}
return convertedChars.ToString();
}
次に、コードを少し変更して次のようにします。
string sDate
DateTime dtt = Convert.ToDateTime("19/01/2012");
CultureInfo ci = new CultureInfo("ar-SA");
sDate = ConvertToEasternArabicNumerals(dtt.ToString("dd/MM/yyyy", ci));
そして、物事はうまくいくでしょう。ところで、関数のコードはここから取得されました。