Ejemplo n.º 1
0
        protected static Encoding GetEncoding(NameRecord record)
        {
            try {
                switch (record.platformID)
                {
                case PlatformID.Unicode:
                    return(Encoding.BigEndianUnicode);

                case PlatformID.Macintosh:
                    switch (record.encodingID)
                    {
                    case 0: return(Encoding.ASCII);

                    case 1: return(Encoding.GetEncoding("x-mac-japanese"));

                    case 2: return(Encoding.GetEncoding("x-mac-chinesetrad"));

                    case 3: return(Encoding.GetEncoding("x-mac-korean"));

                    case 4: return(Encoding.GetEncoding("x-mac-arabic"));

                    case 5: return(Encoding.GetEncoding("x-mac-hebrew"));

                    case 6: return(Encoding.GetEncoding("x-mac-greek"));

                    case 7: return(Encoding.GetEncoding("x-mac-cyrillic"));

                    //case 8: return Encoding.GetEncoding("");
                    case 9: return(Encoding.GetEncoding("x-iscii-de"));

                    //case 10: return Encoding.GetEncoding("");
                    case 11: return(Encoding.GetEncoding("x-iscii-gu"));

                    case 12: return(Encoding.GetEncoding("x-iscii-or"));

                    case 13: return(Encoding.GetEncoding("x-iscii-be"));

                    case 14: return(Encoding.GetEncoding("x-iscii-ta"));

                    case 15: return(Encoding.GetEncoding("x-iscii-te"));

                    case 16: return(Encoding.GetEncoding("x-iscii-ka"));

                    case 17: return(Encoding.GetEncoding("x-iscii-ma"));

                    //case 18: return Encoding.GetEncoding("");
                    case 19: return(Encoding.GetEncoding("Windows-1252"));

                    //case 20: return Encoding.GetEncoding("");
                    case 21: return(Encoding.GetEncoding("x-mac-thai"));

                    //case 22: return Encoding.GetEncoding("");
                    //case 23: return Encoding.GetEncoding("");
                    //case 24: return Encoding.GetEncoding("");
                    case 25: return(Encoding.GetEncoding("x-mac-chinesesimp"));

                    //case 26: return Encoding.GetEncoding("");
                    //case 27: return Encoding.GetEncoding("");
                    //case 28: return Encoding.GetEncoding("");
                    //case 29: return Encoding.GetEncoding("");
                    case 30: return(Encoding.GetEncoding("windows-1258"));
                        //case 31: return Encoding.GetEncoding("");
                        //case 32: return Encoding.GetEncoding("");
                    }
                    break;

                case PlatformID.ISO:
                    switch (record.encodingID)
                    {
                    case 0: return(Encoding.ASCII);

                    case 1: return(Encoding.BigEndianUnicode);

                    case 2: return(Encoding.GetEncoding(1252));
                    }
                    break;

                case PlatformID.Windows:
                    switch (record.encodingID)
                    {
                    case 1: return(Encoding.BigEndianUnicode);

                    case 2: return(Encoding.GetEncoding("shift_jis"));

                    case 3: return(Encoding.GetEncoding("gb2312"));

                    case 4: return(Encoding.GetEncoding("big5"));

                    case 5: return(Encoding.GetEncoding("x-cp20949"));

                    case 6: return(Encoding.GetEncoding("Johab"));

                    case 10: return(Encoding.BigEndianUnicode);
                    }
                    break;
                }
            } catch (System.Exception) {
                return(Encoding.ASCII);
            }
            return(Encoding.ASCII);
        }