상속: EncodingNLS, ISerializable
예제 #1
0
파일: Encoding.cs 프로젝트: enavro/coreclr
        [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;
        }
        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;
        }
예제 #3
0
        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);
        }