機種依存文字の判断 C#

private string IzonCHK(string val)
{
    Encoding sjisEnc = Encoding.GetEncoding("Shift_JIS");

    string resolut = "";
    //1文字ずつ列挙
    for (int i = 0; i < val.Length; i++)
    {
        byte[] bytes;
        bytes = sjisEnc.GetBytes(val[i].ToString());
        int code = 0;
        foreach (byte item in bytes)
        {
            code = item + code * 256;
        }
        if (0xEB40 <= code && code <= 0xEFFC) { resolut += val[i] + ","; }
        if (0x8540 <= code && code <= 0x889E) { resolut += val[i] + ","; }
        if (0x00A0 <= code && code <= 0x00FF) { resolut += val[i] + ","; }
        if (0xF040 <= code) { resolut += val[i] + ","; }

    }
    return resolut;
}
タイトルとURLをコピーしました