Inheritance: DBCSCodePageEncoding
        private static Encoding GetEncodingRare(int codepage)
        {
            Encoding result = null;

            switch (codepage)
            {
                case ISCIIAssemese:
                case ISCIIBengali:
                case ISCIIDevanagari:
                case ISCIIGujarathi:
                case ISCIIKannada:
                case ISCIIMalayalam:
                case ISCIIOriya:
                case ISCIIPanjabi:
                case ISCIITamil:
                case ISCIITelugu:
                    result = new ISCIIEncoding(codepage);
                    break;
                // GB2312-80 uses same code page for 20936 and mac 10008
                case CodePageMacGB2312:
                    //     case CodePageGB2312:
                    //        result = new DBCSCodePageEncoding(codepage, EUCCN);
                    result = new DBCSCodePageEncoding(CodePageMacGB2312, CodePageGB2312);
                    break;

                // Mac Korean 10003 and 20949 are the same
                case CodePageMacKorean:
                    result = new DBCSCodePageEncoding(CodePageMacKorean, CodePageDLLKorean);
                    break;
                // GB18030 Code Pages
                case GB18030:
                    result = new GB18030Encoding();
                    break;
                // ISO2022 Code Pages
                case ISOKorean:
                //    case ISOSimplifiedCN
                case ChineseHZ:
                case ISO2022JP:         // JIS JP, full-width Katakana mode (no half-width Katakana)
                case ISO2022JPESC:      // JIS JP, esc sequence to do Katakana.
                case ISO2022JPSISO:     // JIS JP with Shift In/ Shift Out Katakana support
                    result = new ISO2022Encoding(codepage);
                    break;
                // Duplicate EUC-CN (51936) just calls a base code page 936,
                // so does ISOSimplifiedCN (50227), which's gotta be broken
                case DuplicateEUCCN:
                case ISOSimplifiedCN:
                    result = new DBCSCodePageEncoding(codepage, EUCCN);    // Just maps to 936
                    break;
                case EUCJP:
                    result = new EUCJPEncoding();
                    break;
                case EUCKR:
                    result = new DBCSCodePageEncoding(codepage, CodePageDLLKorean);    // Maps to 20949
                    break;
                case ISO_8859_8I:
                    result = new SBCSCodePageEncoding(codepage, ISO_8859_8_Visual);        // Hebrew maps to a different code page
                    break;
            }
            return result;
        }
        private static Encoding GetEncodingRare(int codepage)
        {
            Encoding result = null;

            switch (codepage)
            {
            case ISCIIAssemese:
            case ISCIIBengali:
            case ISCIIDevanagari:
            case ISCIIGujarathi:
            case ISCIIKannada:
            case ISCIIMalayalam:
            case ISCIIOriya:
            case ISCIIPanjabi:
            case ISCIITamil:
            case ISCIITelugu:
                result = new ISCIIEncoding(codepage);
                break;

            // GB2312-80 uses same code page for 20936 and mac 10008
            case CodePageMacGB2312:
                //     case CodePageGB2312:
                //        result = new DBCSCodePageEncoding(codepage, EUCCN);
                result = new DBCSCodePageEncoding(CodePageMacGB2312, CodePageGB2312);
                break;

            // Mac Korean 10003 and 20949 are the same
            case CodePageMacKorean:
                result = new DBCSCodePageEncoding(CodePageMacKorean, CodePageDLLKorean);
                break;

            // GB18030 Code Pages
            case GB18030:
                result = new GB18030Encoding();
                break;

            // ISO2022 Code Pages
            case ISOKorean:
            //    case ISOSimplifiedCN
            case ChineseHZ:
            case ISO2022JP:             // JIS JP, full-width Katakana mode (no half-width Katakana)
            case ISO2022JPESC:          // JIS JP, esc sequence to do Katakana.
            case ISO2022JPSISO:         // JIS JP with Shift In/ Shift Out Katakana support
                result = new ISO2022Encoding(codepage);
                break;

            // Duplicate EUC-CN (51936) just calls a base code page 936,
            // so does ISOSimplifiedCN (50227), which's gotta be broken
            case DuplicateEUCCN:
            case ISOSimplifiedCN:
                result = new DBCSCodePageEncoding(codepage, EUCCN);        // Just maps to 936
                break;

            case EUCJP:
                result = new EUCJPEncoding();
                break;

            case EUCKR:
                result = new DBCSCodePageEncoding(codepage, CodePageDLLKorean);        // Maps to 20949
                break;

            case ISO_8859_8I:
                result = new SBCSCodePageEncoding(codepage, ISO_8859_8_Visual);            // Hebrew maps to a different code page
                break;
            }
            return(result);
        }
Beispiel #3
0
        [System.Security.SecurityCritical]  // auto-generated
        private static Encoding GetEncodingRare(int codepage)
        {
            Contract.Assert(codepage != 0 && codepage != 1200 && codepage != 1201 && codepage != 65001,
                "[Encoding.GetEncodingRare]This code page (" + codepage + ") isn't supported by GetEncodingRare!");
            Encoding result;
            switch (codepage)
            {
                case CodePageUTF7:              // 65000
                    result = UTF7;
                    break;
                case CodePageUTF32:             // 12000
                    result = UTF32;
                    break;
                case CodePageUTF32BE:           // 12001
                    result = new UTF32Encoding(true, true);
                    break;
                case ISCIIAssemese:
                case ISCIIBengali:
                case ISCIIDevanagari:
                case ISCIIGujarathi:
                case ISCIIKannada:
                case ISCIIMalayalam:
                case ISCIIOriya:
                case ISCIIPanjabi:
                case ISCIITamil:
                case ISCIITelugu:
                    result = new ISCIIEncoding(codepage);
                    break;
                // GB2312-80 uses same code page for 20936 and mac 10008
                case CodePageMacGB2312:
          //     case CodePageGB2312:
          //        result = new DBCSCodePageEncoding(codepage, EUCCN);
                    result = new DBCSCodePageEncoding(CodePageMacGB2312, CodePageGB2312);
                    break;

                // Mac Korean 10003 and 20949 are the same
                case CodePageMacKorean:
                    result = new DBCSCodePageEncoding(CodePageMacKorean, CodePageDLLKorean);
                    break;
                // GB18030 Code Pages
                case GB18030:
                    result = new GB18030Encoding();
                    break;
                // ISO2022 Code Pages
                case ISOKorean:
            //    case ISOSimplifiedCN
                case ChineseHZ:
                case ISO2022JP:         // JIS JP, full-width Katakana mode (no half-width Katakana)
                case ISO2022JPESC:      // JIS JP, esc sequence to do Katakana.
                case ISO2022JPSISO:     // JIS JP with Shift In/ Shift Out Katakana support
                    result = new ISO2022Encoding(codepage);
                    break;
                // Duplicate EUC-CN (51936) just calls a base code page 936,
                // so does ISOSimplifiedCN (50227), which's gotta be broken
                case DuplicateEUCCN:
                case ISOSimplifiedCN:
                    result = new DBCSCodePageEncoding(codepage, EUCCN);    // Just maps to 936
                    break;
                case EUCJP:
                    result = new EUCJPEncoding();
                    break;
                case EUCKR:
                    result = new DBCSCodePageEncoding(codepage, CodePageDLLKorean);    // Maps to 20949
                    break;
                case ENC50229:
                    throw new NotSupportedException(Environment.GetResourceString("NotSupported_CodePage50229"));
                case ISO_8859_8I:
                    result = new SBCSCodePageEncoding(codepage, ISO_8859_8_Visual);        // Hebrew maps to a different code page
                    break;
                default:
                    // Not found, already tried codepage table code pages in GetEncoding()
                    throw new NotSupportedException(
                        Environment.GetResourceString("NotSupported_NoCodepageData", codepage));
            }
            return result;
        }
Beispiel #4
0
        private static Encoding GetEncodingRare(int codepage)
        {
            BCLDebug.Assert(codepage != 0 && codepage != 1200 && codepage != 1201 && codepage != 65001, "This code page (" + codepage + " isn't supported by GetEncodingRare!");
            Encoding result;

            switch (codepage)
            {
            case 1:
            case 2:
            case 3:
            case 42:
                // NOTENOTE YSLin:
                // Win32 also allows the following special code page values.  We won't allow them except in the
                // CP_ACP case.
                // #define CP_ACP                    0           // default to ANSI code page
                // #define CP_OEMCP                  1           // default to OEM  code page
                // #define CP_MACCP                  2           // default to MAC  code page
                // #define CP_THREAD_ACP             3           // current thread's ANSI code page
                // #define CP_SYMBOL                 42          // SYMBOL translations
                throw new ArgumentException(String.Format(Environment.GetResourceString("Argument_CodepageNotSupported"), codepage), "codepage");

            case 65000:
                result = UTF7;
                break;

            case 20127:
                result = ASCII;
                break;

            case ISO_8859_1:
                result = Latin1;
                break;

            case ISOKorean:
                result = new MLangCodePageEncoding(ISOKorean, ISOKorean_SIZE);
                break;

            case ChineseSimp:
                result = new MLangCodePageEncoding(ChineseSimp, ChineseSimp_SIZE);
                break;

            case ISCIIAsseme:
            case ISCIIBengali:
            case ISCIIDevanagari:
            case ISCIIGujarathi:
            case ISCIIKannada:
            case ISCIIMalayalam:
            case ISCIIOriya:
            case ISCIIPanjabi:
            case ISCIITamil:
            case ISCIITelugu:
                result = new MLangCodePageEncoding(codepage, ISCII_SIZE);
                break;

            case ISO2022JP:
                result = new MLangCodePageEncoding(ISO2022JP, ISO2022JP_SIZE);
                break;

            case ENC50221:
                result = new MLangCodePageEncoding(ENC50221, ENC50221_SIZE);
                break;

            case ENC50222:
                result = new MLangCodePageEncoding(ENC50222, ENC50222_SIZE);
                break;

            case ENC50227:
                result = new MLangCodePageEncoding(ENC50227, ENC50227_SIZE);
                break;

            case EUCJP:
                result = new MLangCodePageEncoding(EUCJP, EUCJP_SIZE);
                break;

            case GB18030:
                result = new GB18030Encoding();
                break;

            case EUCCN:
                result = new MLangCodePageEncoding(EUCCN, EUCCN_SIZE);
                break;

            case ENC50229:
                throw new NotSupportedException(Environment.GetResourceString("NotSupported_CodePage50229"));

            default:
                result = new CodePageEncoding(codepage);
                break;
            }
            return(result);
        }