Пример #1
0
 internal BaseCodePageEncoding(int codepage, int dataCodePage, EncoderFallback enc, DecoderFallback dec)
     : base(codepage, enc, dec)
 {
     // Remember number of code pages that we'll be using the table for.
     dataTableCodePage = dataCodePage;
     LoadCodePageTables();
 }
Пример #2
0
        // Constructor called by serialization.
        internal CodePageEncoding(SerializationInfo info, StreamingContext context)
        {
            // Any info?
            if (info==null) throw new ArgumentNullException(nameof(info));
            Contract.EndContractBlock();

            // All versions have a code page
            this.m_codePage = (int)info.GetValue("m_codePage", typeof(int));

            // See if we have a code page
            try
            {
                //
                // Try Whidbey V2.0 Fields
                //
                this.m_isReadOnly = (bool)info.GetValue("m_isReadOnly", typeof(bool));

                this.encoderFallback = (EncoderFallback)info.GetValue("encoderFallback", typeof(EncoderFallback));
                this.decoderFallback = (DecoderFallback)info.GetValue("decoderFallback", typeof(DecoderFallback));
            }
            catch (SerializationException)
            {
                //
                // Didn't have Whidbey things, must be Everett
                //
                this.m_deserializedFromEverett = true;

                // May as well be read only
                this.m_isReadOnly = true;
            }
        }
Пример #3
0
 protected CodePageEncoding(int codePage, string name, string webName, EncoderFallback encoderFallback, DecoderFallback decoderFallback)
     : base(codePage, encoderFallback, decoderFallback)
 {
     codePage_ = codePage;
     encodingName_ = name;
     webName_ = webName;
 }
Пример #4
0
 internal DecoderNLSSurrogate(SerializationInfo info, StreamingContext context)
 {
     if (info == null)
     {
         throw new ArgumentNullException(nameof(info));
     }
     _encoding = (Encoding)info.GetValue(EncodingKey, typeof(Encoding));
     _fallback = (DecoderFallback)info.GetValue(DecoderFallbackKey, typeof(DecoderFallback));
 }
Пример #5
0
        public virtual Encoding GetEncoding(int codepage, EncoderFallback encoderFallback, DecoderFallback decoderFallback)
        {
            Encoding enc = GetEncoding(codepage);
            if (enc != null)
            {
                enc = (Encoding)GetEncoding(codepage).Clone();
                enc.EncoderFallback = encoderFallback;
                enc.DecoderFallback = decoderFallback;
            }

            return enc;
        }
    static bool Encoding_GetEncoding__String__EncoderFallback__DecoderFallback(JSVCall vc, int argc)
    {
        int len = argc;

        if (len == 3)
        {
            System.String arg0 = (System.String)JSApi.getStringS((int)JSApi.GetType.Arg);
            System.Text.EncoderFallback arg1 = (System.Text.EncoderFallback)JSMgr.datax.getObject((int)JSApi.GetType.Arg);
            System.Text.DecoderFallback arg2 = (System.Text.DecoderFallback)JSMgr.datax.getObject((int)JSApi.GetType.Arg);
            JSMgr.datax.setObject((int)JSApi.SetType.Rval, System.Text.Encoding.GetEncoding(arg0, arg1, arg2));
        }

        return(true);
    }
 static void Encoding_DecoderFallback(JSVCall vc)
 {
     if (vc.bGet)
     {
         System.Text.Encoding _this = (System.Text.Encoding)vc.csObj;
         var result = _this.DecoderFallback;
         JSMgr.datax.setObject((int)JSApi.SetType.Rval, result);
     }
     else
     {
         System.Text.DecoderFallback arg0  = (System.Text.DecoderFallback)JSMgr.datax.getObject((int)JSApi.GetType.Arg);
         System.Text.Encoding        _this = (System.Text.Encoding)vc.csObj;
         _this.DecoderFallback = arg0;
     }
 }
Пример #8
0
        // Determine if two Encoding objects are equal.
        public override bool Equals(Object value)
        {
            Encoding enc = (value as Encoding);

            if (enc != null)
            {
#if NET_2_0
                return(codePage == enc.codePage &&
                       DecoderFallback.Equals(enc.DecoderFallback) &&
                       EncoderFallback.Equals(enc.EncoderFallback));
#else
                return(codePage == enc.codePage);
#endif
            }
            else
            {
                return(false);
            }
        }
 internal CodePageEncoding(SerializationInfo info, StreamingContext context)
 {
     if (info == null)
     {
         throw new ArgumentNullException("info");
     }
     this.m_codePage = (int)info.GetValue("m_codePage", typeof(int));
     try
     {
         this.m_isReadOnly    = (bool)info.GetValue("m_isReadOnly", typeof(bool));
         this.encoderFallback = (EncoderFallback)info.GetValue("encoderFallback", typeof(EncoderFallback));
         this.decoderFallback = (DecoderFallback)info.GetValue("decoderFallback", typeof(DecoderFallback));
     }
     catch (SerializationException)
     {
         this.m_deserializedFromEverett = true;
         this.m_isReadOnly = true;
     }
 }
Пример #10
0
        public static Encoding GetEncoding(string name,
                                           EncoderFallback encoderFallback, DecoderFallback decoderFallback)
        {
            if (encoderFallback == null)
            {
                throw new ArgumentNullException("encoderFallback");
            }
            if (decoderFallback == null)
            {
                throw new ArgumentNullException("decoderFallback");
            }

            Encoding e = GetEncoding(name).Clone() as Encoding;

            e.is_readonly      = false;
            e.encoder_fallback = encoderFallback;
            e.decoder_fallback = decoderFallback;
            return(e);
        }
 internal MLangCodePageEncoding(SerializationInfo info, StreamingContext context)
 {
     if (info == null)
     {
         throw new ArgumentNullException("info");
     }
     this.m_codePage = (int) info.GetValue("m_codePage", typeof(int));
     try
     {
         this.m_isReadOnly = (bool) info.GetValue("m_isReadOnly", typeof(bool));
         this.encoderFallback = (EncoderFallback) info.GetValue("encoderFallback", typeof(EncoderFallback));
         this.decoderFallback = (DecoderFallback) info.GetValue("decoderFallback", typeof(DecoderFallback));
     }
     catch (SerializationException)
     {
         this.m_deserializedFromEverett = true;
         this.m_isReadOnly = true;
     }
 }
Пример #12
0
        private MLangCodePageEncoding(SerializationInfo info, StreamingContext context)
        {
            if (info == null)
            {
                throw new ArgumentNullException("info");
            }

            this.codePage = (int)info.GetValue("m_codePage", typeof(int));

#if NET_2_0
            try {
                this.isReadOnly      = (bool)info.GetValue("m_isReadOnly", typeof(bool));
                this.encoderFallback = (EncoderFallback)info.GetValue("encoderFallback", typeof(EncoderFallback));
                this.decoderFallback = (DecoderFallback)info.GetValue("decoderFallback", typeof(DecoderFallback));
            } catch (SerializationException) {
                // .NET Framework 1.x has no fallbacks
                this.isReadOnly = true;
            }
#endif
        }
        // Constructor called by serialization.
        internal MLangCodePageEncoding(SerializationInfo info, StreamingContext context)
        {
            // Any info?
            if (info==null) throw new ArgumentNullException("info");

            // All versions have a code page
            this.m_codePage = (int)info.GetValue("m_codePage", typeof(int));

            // See if we have a code page
            try
            {
                this.m_isReadOnly = (bool)info.GetValue("m_isReadOnly", typeof(bool));

                this.encoderFallback = (EncoderFallback)info.GetValue("encoderFallback", typeof(EncoderFallback));
                this.decoderFallback = (DecoderFallback)info.GetValue("decoderFallback", typeof(DecoderFallback));
            }
            catch (SerializationException)
            {
                this.m_deserializedFromEverett = true;

                // May as well be read only
                this.m_isReadOnly = true;
            }
        }
Пример #14
0
	public static Encoding GetEncoding (string name,
		EncoderFallback encoderFallback, DecoderFallback decoderFallback)
	{
		if (encoderFallback == null)
			throw new ArgumentNullException ("encoderFallback");
		if (decoderFallback == null)
			throw new ArgumentNullException ("decoderFallback");

		Encoding e = GetEncoding (name).Clone () as Encoding;
		e.is_readonly = false;
		e.encoder_fallback = encoderFallback;
		e.decoder_fallback = decoderFallback;
		return e;
	}
Пример #15
0
 internal DecoderNLS(EncodingNLS encoding)
 {
     m_encoding = encoding;
     m_fallback = m_encoding.DecoderFallback;
     Reset();
 }
Пример #16
0
        // Default fallback that we'll use. 
        internal virtual void SetDefaultFallbacks()
        { 
#if FEATURE_CORECLR
            // For coreclr we only have Unicode, so we don't have best fit fallbacks
            this.encoderFallback = new EncoderReplacementFallback("\xFFFD");
            this.decoderFallback = new DecoderReplacementFallback("\xFFFD"); 
#else // !FEATURE_CORECLR
            // For UTF-X encodings, we use a replacement fallback with an "\xFFFD" string, 
            // For ASCII we use "?" replacement fallback, etc. 
            this.encoderFallback = new InternalEncoderBestFitFallback(this);
            this.decoderFallback = new InternalDecoderBestFitFallback(this); 
#endif // FEATURE_CORECLR
        }
Пример #17
0
 public static Windows1250Encoding Create(EncoderFallback encoder, DecoderFallback decoder)
 {
     return new Windows1250Encoding(encoder, decoder);
 }
Пример #18
0
        [MethodImpl(MethodImplOptions.AggressiveInlining)] // called directly by GetCharCountCommon
        private protected sealed override unsafe int GetCharCountFast(byte *pBytes, int bytesLength, DecoderFallback fallback, out int bytesConsumed)
        {
            // The number of UTF-16 code units will never exceed the number of UTF-8 code units,
            // so the addition at the end of this method will not overflow.

            byte *ptrToFirstInvalidByte = Utf8Utility.GetPointerToFirstInvalidByte(pBytes, bytesLength, out int utf16CodeUnitCountAdjustment, out _);

            int tempBytesConsumed = (int)(ptrToFirstInvalidByte - pBytes);

            bytesConsumed = tempBytesConsumed;

            return(tempBytesConsumed + utf16CodeUnitCountAdjustment);
        }
Пример #19
0
 private static Encoding CreateEncoding(int codepage, EncoderFallback/*!*/ encoderFallback, DecoderFallback/*!*/ decoderFallback) {
     return Create(Encoding.GetEncoding(codepage, encoderFallback, decoderFallback));
 }
Пример #20
0
 // Token: 0x0600677A RID: 26490 RVA: 0x0015C860 File Offset: 0x0015AA60
 internal static Encoding GetEncodingFromProvider(int codepage, EncoderFallback enc, DecoderFallback dec)
 {
     if (EncodingProvider.s_providers == null)
     {
         return(null);
     }
     EncodingProvider[] array = EncodingProvider.s_providers;
     foreach (EncodingProvider encodingProvider in array)
     {
         Encoding encoding = encodingProvider.GetEncoding(codepage, enc, dec);
         if (encoding != null)
         {
             return(encoding);
         }
     }
     return(null);
 }
Пример #21
0
        public Windows1253Encoding(EncoderFallback encoderFallback, DecoderFallback decoderFallback)
            : base(1253, "Greece (Windows)", "windows-1253", encoderFallback, decoderFallback)
        {
            byteToChars_ = new char[]
            {
                          '\u0000' // ''
                        , '\u0001' // ''
                        , '\u0002' // ''
                        , '\u0003' // ''
                        , '\u0004' // ''
                        , '\u0005' // ''
                        , '\u0006' // ''
                        , '\u0007' // ''
                        , '\u0008' // ''
                        , '\u0009' // '<TAB>'
                        , '\u000a' // '<LF>'
                        , '\u000b' // ''
                        , '\u000c' // ''
                        , '\u000d' // '<CR>'
                        , '\u000e' // ''
                        , '\u000f' // ''
                        , '\u0010' // ''
                        , '\u0011' // ''
                        , '\u0012' // ''
                        , '\u0013' // ''
                        , '\u0014' // ''
                        , '\u0015' // ''
                        , '\u0016' // ''
                        , '\u0017' // ''
                        , '\u0018' // ''
                        , '\u0019' // ''
                        , '\u001a' // ''
                        , '\u001b' // ''
                        , '\u001c' // ''
                        , '\u001d' // ''
                        , '\u001e' // ''
                        , '\u001f' // ''
                        , '\u0020' // ' '
                        , '\u0021' // '!'
                        , '\u0022' // '"'
                        , '\u0023' // '#'
                        , '\u0024' // '$'
                        , '\u0025' // '%'
                        , '\u0026' // '&'
                        , '\u0027' // '''
                        , '\u0028' // '('
                        , '\u0029' // ')'
                        , '\u002a' // '*'
                        , '\u002b' // '+'
                        , '\u002c' // ','
                        , '\u002d' // '-'
                        , '\u002e' // '.'
                        , '\u002f' // '/'
                        , '\u0030' // '0'
                        , '\u0031' // '1'
                        , '\u0032' // '2'
                        , '\u0033' // '3'
                        , '\u0034' // '4'
                        , '\u0035' // '5'
                        , '\u0036' // '6'
                        , '\u0037' // '7'
                        , '\u0038' // '8'
                        , '\u0039' // '9'
                        , '\u003a' // ':'
                        , '\u003b' // ';'
                        , '\u003c' // '<'
                        , '\u003d' // '='
                        , '\u003e' // '>'
                        , '\u003f' // '?'
                        , '\u0040' // '@'
                        , '\u0041' // 'A'
                        , '\u0042' // 'B'
                        , '\u0043' // 'C'
                        , '\u0044' // 'D'
                        , '\u0045' // 'E'
                        , '\u0046' // 'F'
                        , '\u0047' // 'G'
                        , '\u0048' // 'H'
                        , '\u0049' // 'I'
                        , '\u004a' // 'J'
                        , '\u004b' // 'K'
                        , '\u004c' // 'L'
                        , '\u004d' // 'M'
                        , '\u004e' // 'N'
                        , '\u004f' // 'O'
                        , '\u0050' // 'P'
                        , '\u0051' // 'Q'
                        , '\u0052' // 'R'
                        , '\u0053' // 'S'
                        , '\u0054' // 'T'
                        , '\u0055' // 'U'
                        , '\u0056' // 'V'
                        , '\u0057' // 'W'
                        , '\u0058' // 'X'
                        , '\u0059' // 'Y'
                        , '\u005a' // 'Z'
                        , '\u005b' // '['
                        , '\u005c' // '\'
                        , '\u005d' // ']'
                        , '\u005e' // '^'
                        , '\u005f' // '_'
                        , '\u0060' // '`'
                        , '\u0061' // 'a'
                        , '\u0062' // 'b'
                        , '\u0063' // 'c'
                        , '\u0064' // 'd'
                        , '\u0065' // 'e'
                        , '\u0066' // 'f'
                        , '\u0067' // 'g'
                        , '\u0068' // 'h'
                        , '\u0069' // 'i'
                        , '\u006a' // 'j'
                        , '\u006b' // 'k'
                        , '\u006c' // 'l'
                        , '\u006d' // 'm'
                        , '\u006e' // 'n'
                        , '\u006f' // 'o'
                        , '\u0070' // 'p'
                        , '\u0071' // 'q'
                        , '\u0072' // 'r'
                        , '\u0073' // 's'
                        , '\u0074' // 't'
                        , '\u0075' // 'u'
                        , '\u0076' // 'v'
                        , '\u0077' // 'w'
                        , '\u0078' // 'x'
                        , '\u0079' // 'y'
                        , '\u007a' // 'z'
                        , '\u007b' // '{'
                        , '\u007c' // '|'
                        , '\u007d' // '}'
                        , '\u007e' // '~'
                        , '\u007f' // ''
                        , '\u20ac' // '€'
                        , '\u0081' // ''
                        , '\u201a' // '‚'
                        , '\u0192' // 'ƒ'
                        , '\u201e' // '„'
                        , '\u2026' // '…'
                        , '\u2020' // '†'
                        , '\u2021' // '‡'
                        , '\u0088' // 'ˆ'
                        , '\u2030' // '‰'
                        , '\u008a' // 'Š'
                        , '\u2039' // '‹'
                        , '\u008c' // 'Œ'
                        , '\u008d' // ''
                        , '\u008e' // 'Ž'
                        , '\u008f' // ''
                        , '\u0090' // ''
                        , '\u2018' // '‘'
                        , '\u2019' // '’'
                        , '\u201c' // '“'
                        , '\u201d' // '”'
                        , '\u2022' // '•'
                        , '\u2013' // '–'
                        , '\u2014' // '—'
                        , '\u0098' // '˜'
                        , '\u2122' // '™'
                        , '\u009a' // 'š'
                        , '\u203a' // '›'
                        , '\u009c' // 'œ'
                        , '\u009d' // ''
                        , '\u009e' // 'ž'
                        , '\u009f' // 'Ÿ'
                        , '\u00a0' // ' '
                        , '\u0385' // '΅'
                        , '\u0386' // 'Ά'
                        , '\u00a3' // '£'
                        , '\u00a4' // '¤'
                        , '\u00a5' // '¥'
                        , '\u00a6' // '¦'
                        , '\u00a7' // '§'
                        , '\u00a8' // '¨'
                        , '\u00a9' // '©'
                        , '\uf8f9' // ''
                        , '\u00ab' // '«'
                        , '\u00ac' // '¬'
                        , '\u00ad' // '­'
                        , '\u00ae' // '®'
                        , '\u2015' // '―'
                        , '\u00b0' // '°'
                        , '\u00b1' // '±'
                        , '\u00b2' // '²'
                        , '\u00b3' // '³'
                        , '\u0384' // '΄'
                        , '\u00b5' // 'µ'
                        , '\u00b6' // '¶'
                        , '\u00b7' // '·'
                        , '\u0388' // 'Έ'
                        , '\u0389' // 'Ή'
                        , '\u038a' // 'Ί'
                        , '\u00bb' // '»'
                        , '\u038c' // 'Ό'
                        , '\u00bd' // '½'
                        , '\u038e' // 'Ύ'
                        , '\u038f' // 'Ώ'
                        , '\u0390' // 'ΐ'
                        , '\u0391' // 'Α'
                        , '\u0392' // 'Β'
                        , '\u0393' // 'Γ'
                        , '\u0394' // 'Δ'
                        , '\u0395' // 'Ε'
                        , '\u0396' // 'Ζ'
                        , '\u0397' // 'Η'
                        , '\u0398' // 'Θ'
                        , '\u0399' // 'Ι'
                        , '\u039a' // 'Κ'
                        , '\u039b' // 'Λ'
                        , '\u039c' // 'Μ'
                        , '\u039d' // 'Ν'
                        , '\u039e' // 'Ξ'
                        , '\u039f' // 'Ο'
                        , '\u03a0' // 'Π'
                        , '\u03a1' // 'Ρ'
                        , '\uf8fa' // ''
                        , '\u03a3' // 'Σ'
                        , '\u03a4' // 'Τ'
                        , '\u03a5' // 'Υ'
                        , '\u03a6' // 'Φ'
                        , '\u03a7' // 'Χ'
                        , '\u03a8' // 'Ψ'
                        , '\u03a9' // 'Ω'
                        , '\u03aa' // 'Ϊ'
                        , '\u03ab' // 'Ϋ'
                        , '\u03ac' // 'ά'
                        , '\u03ad' // 'έ'
                        , '\u03ae' // 'ή'
                        , '\u03af' // 'ί'
                        , '\u03b0' // 'ΰ'
                        , '\u03b1' // 'α'
                        , '\u03b2' // 'β'
                        , '\u03b3' // 'γ'
                        , '\u03b4' // 'δ'
                        , '\u03b5' // 'ε'
                        , '\u03b6' // 'ζ'
                        , '\u03b7' // 'η'
                        , '\u03b8' // 'θ'
                        , '\u03b9' // 'ι'
                        , '\u03ba' // 'κ'
                        , '\u03bb' // 'λ'
                        , '\u03bc' // 'μ'
                        , '\u03bd' // 'ν'
                        , '\u03be' // 'ξ'
                        , '\u03bf' // 'ο'
                        , '\u03c0' // 'π'
                        , '\u03c1' // 'ρ'
                        , '\u03c2' // 'ς'
                        , '\u03c3' // 'σ'
                        , '\u03c4' // 'τ'
                        , '\u03c5' // 'υ'
                        , '\u03c6' // 'φ'
                        , '\u03c7' // 'χ'
                        , '\u03c8' // 'ψ'
                        , '\u03c9' // 'ω'
                        , '\u03ca' // 'ϊ'
                        , '\u03cb' // 'ϋ'
                        , '\u03cc' // 'ό'
                        , '\u03cd' // 'ύ'
                        , '\u03ce' // 'ώ'
                        , '\uf8fb' // ''
                };

            charToBytes_ = new Dictionary<char, byte>()
            {
                        { /* '€' */ '\u20ac', 128 },
                        { /* '‚' */ '\u201a', 130 },
                        { /* 'ƒ' */ '\u0192', 131 },
                        { /* '„' */ '\u201e', 132 },
                        { /* '…' */ '\u2026', 133 },
                        { /* '†' */ '\u2020', 134 },
                        { /* '‡' */ '\u2021', 135 },
                        { /* '‰' */ '\u2030', 137 },
                        { /* '‹' */ '\u2039', 139 },
                        { /* '‘' */ '\u2018', 145 },
                        { /* '’' */ '\u2019', 146 },
                        { /* '“' */ '\u201c', 147 },
                        { /* '”' */ '\u201d', 148 },
                        { /* '•' */ '\u2022', 149 },
                        { /* '–' */ '\u2013', 150 },
                        { /* '—' */ '\u2014', 151 },
                        { /* '™' */ '\u2122', 153 },
                        { /* '›' */ '\u203a', 155 },
                        { /* '΅' */ '\u0385', 161 },
                        { /* 'Ά' */ '\u0386', 162 },
                        { /* '' */ '\uf8f9', 170 },
                        { /* '―' */ '\u2015', 175 },
                        { /* '΄' */ '\u0384', 180 },
                        { /* 'Έ' */ '\u0388', 184 },
                        { /* 'Ή' */ '\u0389', 185 },
                        { /* 'Ί' */ '\u038a', 186 },
                        { /* 'Ό' */ '\u038c', 188 },
                        { /* 'Ύ' */ '\u038e', 190 },
                        { /* 'Ώ' */ '\u038f', 191 },
                        { /* 'ΐ' */ '\u0390', 192 },
                        { /* 'Α' */ '\u0391', 193 },
                        { /* 'Β' */ '\u0392', 194 },
                        { /* 'Γ' */ '\u0393', 195 },
                        { /* 'Δ' */ '\u0394', 196 },
                        { /* 'Ε' */ '\u0395', 197 },
                        { /* 'Ζ' */ '\u0396', 198 },
                        { /* 'Η' */ '\u0397', 199 },
                        { /* 'Θ' */ '\u0398', 200 },
                        { /* 'Ι' */ '\u0399', 201 },
                        { /* 'Κ' */ '\u039a', 202 },
                        { /* 'Λ' */ '\u039b', 203 },
                        { /* 'Μ' */ '\u039c', 204 },
                        { /* 'Ν' */ '\u039d', 205 },
                        { /* 'Ξ' */ '\u039e', 206 },
                        { /* 'Ο' */ '\u039f', 207 },
                        { /* 'Π' */ '\u03a0', 208 },
                        { /* 'Ρ' */ '\u03a1', 209 },
                        { /* '' */ '\uf8fa', 210 },
                        { /* 'Σ' */ '\u03a3', 211 },
                        { /* 'Τ' */ '\u03a4', 212 },
                        { /* 'Υ' */ '\u03a5', 213 },
                        { /* 'Φ' */ '\u03a6', 214 },
                        { /* 'Χ' */ '\u03a7', 215 },
                        { /* 'Ψ' */ '\u03a8', 216 },
                        { /* 'Ω' */ '\u03a9', 217 },
                        { /* 'Ϊ' */ '\u03aa', 218 },
                        { /* 'Ϋ' */ '\u03ab', 219 },
                        { /* 'ά' */ '\u03ac', 220 },
                        { /* 'έ' */ '\u03ad', 221 },
                        { /* 'ή' */ '\u03ae', 222 },
                        { /* 'ί' */ '\u03af', 223 },
                        { /* 'ΰ' */ '\u03b0', 224 },
                        { /* 'α' */ '\u03b1', 225 },
                        { /* 'β' */ '\u03b2', 226 },
                        { /* 'γ' */ '\u03b3', 227 },
                        { /* 'δ' */ '\u03b4', 228 },
                        { /* 'ε' */ '\u03b5', 229 },
                        { /* 'ζ' */ '\u03b6', 230 },
                        { /* 'η' */ '\u03b7', 231 },
                        { /* 'θ' */ '\u03b8', 232 },
                        { /* 'ι' */ '\u03b9', 233 },
                        { /* 'κ' */ '\u03ba', 234 },
                        { /* 'λ' */ '\u03bb', 235 },
                        { /* 'μ' */ '\u03bc', 236 },
                        { /* 'ν' */ '\u03bd', 237 },
                        { /* 'ξ' */ '\u03be', 238 },
                        { /* 'ο' */ '\u03bf', 239 },
                        { /* 'π' */ '\u03c0', 240 },
                        { /* 'ρ' */ '\u03c1', 241 },
                        { /* 'ς' */ '\u03c2', 242 },
                        { /* 'σ' */ '\u03c3', 243 },
                        { /* 'τ' */ '\u03c4', 244 },
                        { /* 'υ' */ '\u03c5', 245 },
                        { /* 'φ' */ '\u03c6', 246 },
                        { /* 'χ' */ '\u03c7', 247 },
                        { /* 'ψ' */ '\u03c8', 248 },
                        { /* 'ω' */ '\u03c9', 249 },
                        { /* 'ϊ' */ '\u03ca', 250 },
                        { /* 'ϋ' */ '\u03cb', 251 },
                        { /* 'ό' */ '\u03cc', 252 },
                        { /* 'ύ' */ '\u03cd', 253 },
                        { /* 'ώ' */ '\u03ce', 254 },
                        { /* '' */ '\uf8fb', 255 },
            };
        }
Пример #22
0
        internal static Encoding GetEncodingFromProvider(int codepage, EncoderFallback enc, DecoderFallback dec)
        {
            if (s_providers == null)
                return null;

            var providers = s_providers;
            foreach (EncodingProvider provider in providers)
            {
                Encoding encing = provider.GetEncoding(codepage, enc, dec);
                if (encing != null)
                    return encing;
            }

            return null;
        }
Пример #23
0
 internal void OnDeserializing()
 {
     encoderFallback = null;
     decoderFallback = null;
     m_isReadOnly    = true;
 }
        public static System.Text.Encoding GetEncoding(string name, EncoderFallback encoderFallback, DecoderFallback decoderFallback)
        {
            Contract.Ensures(Contract.Result <System.Text.Encoding>() != null);

            return(default(System.Text.Encoding));
        }
Пример #25
0
        // the following two methods are used for the inherited classes which implemented ISerializable
        // Deserialization Helper
        internal void DeserializeEncoding(SerializationInfo info, StreamingContext context)
        {
            // Any info?
            if (info==null) throw new ArgumentNullException("info");
            Contract.EndContractBlock();

            // All versions have a code page
            this.m_codePage = (int)info.GetValue("m_codePage", typeof(int));

            // We can get dataItem on the fly if needed, and the index is different between versions
            // so ignore whatever dataItem data we get from Everett.
            this.dataItem   = null;

            // See if we have a code page
            try
            {
                //
                // Try Whidbey V2.0 Fields
                //

                this.m_isReadOnly = (bool)info.GetValue("m_isReadOnly", typeof(bool));

                this.encoderFallback = (EncoderFallback)info.GetValue("encoderFallback", typeof(EncoderFallback));
                this.decoderFallback = (DecoderFallback)info.GetValue("decoderFallback", typeof(DecoderFallback));
            }
            catch (SerializationException)
            {
                //
                // Didn't have Whidbey things, must be Everett
                //
                this.m_deserializedFromEverett = true;

                // May as well be read only
                this.m_isReadOnly = true;
                SetDefaultFallbacks();
            }
        }
Пример #26
0
        [MethodImpl(MethodImplOptions.AggressiveInlining)] // called directly by GetCharCountCommon
        private protected sealed override unsafe int GetCharCountFast(byte *pBytes, int bytesLength, DecoderFallback fallback, out int bytesConsumed)
        {
            // First: Can we short-circuit the entire calculation?
            // If a DecoderReplacementFallback is in use, all non-ASCII bytes are replaced with
            // the default string. If the default string consists of a single BMP value, then we
            // know there's a 1:1 byte->char transcoding in all cases.

            int charCount = bytesLength;

            if (!(fallback is DecoderReplacementFallback replacementFallback) || replacementFallback.MaxCharCount != 1)
            {
                // Unrecognized fallback mechanism - count bytes manually.

                charCount = (int)ASCIIUtility.GetIndexOfFirstNonAsciiByte(pBytes, (uint)bytesLength);
            }

            bytesConsumed = charCount;
            return(charCount);
        }
Пример #27
0
 public static KCoding Create(int codepage, EncoderFallback/*!*/ encoderFallback, DecoderFallback/*!*/ decoderFallback) {
     var encoding = CreateEncoding(codepage, encoderFallback, decoderFallback);
     return encoding != null ? Create(encoding) : null;
 }
Пример #28
0
		// Constructor.
		public UTF8Decoder (DecoderFallback fallback)
		{
			Fallback = fallback;
			leftOverBits = 0;
			leftOverCount = 0;
		}
Пример #29
0
        public Windows1252Encoding(EncoderFallback encoderFallback, DecoderFallback decoderFallback)
            : base(1252, "Western Europe (Windows)", "Windows-1252", encoderFallback, decoderFallback)
        {
            byteToChars_ = new char[]
            {
                      '\u0000' // NULL
                    , '\u0001' // SOH
                    , '\u0002' // STX
                    , '\u0003' // ETX
                    , '\u0004' // EOT
                    , '\u0005' // ENQ
                    , '\u0006' // ACK
                    , '\u0007' // BEL
                    , '\u0008' // BS
                    , '\u0009' // TAB
                    , '\u000a' // LF
                    , '\u000b' // VT
                    , '\u000c' // FF
                    , '\u000d' // CR
                    , '\u000e' // SO
                    , '\u000f' // SI
                    , '\u0010' // DLE
                    , '\u0011' // DC1
                    , '\u0012' // DC2
                    , '\u0013' // DC3
                    , '\u0014' // DC4
                    , '\u0015' // NAK
                    , '\u0016' // SYN
                    , '\u0017' // ETB
                    , '\u0018' // CAN
                    , '\u0019' // EM
                    , '\u001a' // SUB
                    , '\u001b' // ESC
                    , '\u001c' // FS
                    , '\u001d' // GS
                    , '\u001e' // RS
                    , '\u001f' // US
                    , '\u0020' // ' '
                    , '\u0021' // '!'
                    , '\u0022' // '"'
                    , '\u0023' // '#'
                    , '\u0024' // '$'
                    , '\u0025' // '%'
                    , '\u0026' // '&'
                    , '\u0027' // '''
                    , '\u0028' // '('
                    , '\u0029' // ')'
                    , '\u002a' // '*'
                    , '\u002b' // '+'
                    , '\u002c' // ','
                    , '\u002d' // '-'
                    , '\u002e' // '.'
                    , '\u002f' // '/'
                    , '\u0030' // '0'
                    , '\u0031' // '1'
                    , '\u0032' // '2'
                    , '\u0033' // '3'
                    , '\u0034' // '4'
                    , '\u0035' // '5'
                    , '\u0036' // '6'
                    , '\u0037' // '7'
                    , '\u0038' // '8'
                    , '\u0039' // '9'
                    , '\u003a' // ':'
                    , '\u003b' // ';'
                    , '\u003c' // '<'
                    , '\u003d' // '='
                    , '\u003e' // '>'
                    , '\u003f' // '?'
                    , '\u0040' // '@'
                    , '\u0041' // 'A'
                    , '\u0042' // 'B'
                    , '\u0043' // 'C'
                    , '\u0044' // 'D'
                    , '\u0045' // 'E'
                    , '\u0046' // 'F'
                    , '\u0047' // 'G'
                    , '\u0048' // 'H'
                    , '\u0049' // 'I'
                    , '\u004a' // 'J'
                    , '\u004b' // 'K'
                    , '\u004c' // 'L'
                    , '\u004d' // 'M'
                    , '\u004e' // 'N'
                    , '\u004f' // 'O'
                    , '\u0050' // 'P'
                    , '\u0051' // 'Q'
                    , '\u0052' // 'R'
                    , '\u0053' // 'S'
                    , '\u0054' // 'T'
                    , '\u0055' // 'U'
                    , '\u0056' // 'V'
                    , '\u0057' // 'W'
                    , '\u0058' // 'X'
                    , '\u0059' // 'Y'
                    , '\u005a' // 'Z'
                    , '\u005b' // '['
                    , '\u005c' // '\'
                    , '\u005d' // ']'
                    , '\u005e' // '^'
                    , '\u005f' // '_'
                    , '\u0060' // '`'
                    , '\u0061' // 'a'
                    , '\u0062' // 'b'
                    , '\u0063' // 'c'
                    , '\u0064' // 'd'
                    , '\u0065' // 'e'
                    , '\u0066' // 'f'
                    , '\u0067' // 'g'
                    , '\u0068' // 'h'
                    , '\u0069' // 'i'
                    , '\u006a' // 'j'
                    , '\u006b' // 'k'
                    , '\u006c' // 'l'
                    , '\u006d' // 'm'
                    , '\u006e' // 'n'
                    , '\u006f' // 'o'
                    , '\u0070' // 'p'
                    , '\u0071' // 'q'
                    , '\u0072' // 'r'
                    , '\u0073' // 's'
                    , '\u0074' // 't'
                    , '\u0075' // 'u'
                    , '\u0076' // 'v'
                    , '\u0077' // 'w'
                    , '\u0078' // 'x'
                    , '\u0079' // 'y'
                    , '\u007a' // 'z'
                    , '\u007b' // '{'
                    , '\u007c' // '|'
                    , '\u007d' // '}'
                    , '\u007e' // '~'
                    , '\u007f' // ''
                    , '\u20ac' // '€'
                    , '\u0081' // not mapped
                    , '\u201a' // '‚'
                    , '\u0192' // 'ƒ'
                    , '\u201e' // '„'
                    , '\u2026' // '…'
                    , '\u2020' // '†'
                    , '\u2021' // '‡'
                    , '\u02c6' // 'ˆ'
                    , '\u2030' // '‰'
                    , '\u0160' // 'Š'
                    , '\u2039' // '‹'
                    , '\u0152' // 'Œ'
                    , '\u008d' // not mapped
                    , '\u017d' // 'Ž'
                    , '\u008f' // not mapped
                    , '\u0090' // not mapped
                    , '\u2018' // '‘'
                    , '\u2019' // '’'
                    , '\u201c' // '“'
                    , '\u201d' // '”'
                    , '\u2022' // '•'
                    , '\u2013' // '–'
                    , '\u2014' // '—'
                    , '\u02dc' // '˜'
                    , '\u2122' // '™'
                    , '\u0161' // 'š'
                    , '\u203a' // '›'
                    , '\u0153' // 'œ'
                    , '\u009d' // not mapped
                    , '\u017e' // 'ž'
                    , '\u0178' // 'Ÿ'
                    , '\u00a0' // ' '
                    , '\u00a1' // '¡'
                    , '\u00a2' // '¢'
                    , '\u00a3' // '£'
                    , '\u00a4' // '¤'
                    , '\u00a5' // '¥'
                    , '\u00a6' // '¦'
                    , '\u00a7' // '§'
                    , '\u00a8' // '¨'
                    , '\u00a9' // '©'
                    , '\u00aa' // 'ª'
                    , '\u00ab' // '«'
                    , '\u00ac' // '¬'
                    , '\u00ad' // '­'
                    , '\u00ae' // '®'
                    , '\u00af' // '¯'
                    , '\u00b0' // '°'
                    , '\u00b1' // '±'
                    , '\u00b2' // '²'
                    , '\u00b3' // '³'
                    , '\u00b4' // '´'
                    , '\u00b5' // 'µ'
                    , '\u00b6' // '¶'
                    , '\u00b7' // '·'
                    , '\u00b8' // '¸'
                    , '\u00b9' // '¹'
                    , '\u00ba' // 'º'
                    , '\u00bb' // '»'
                    , '\u00bc' // '¼'
                    , '\u00bd' // '½'
                    , '\u00be' // '¾'
                    , '\u00bf' // '¿'
                    , '\u00c0' // 'À'
                    , '\u00c1' // 'Á'
                    , '\u00c2' // 'Â'
                    , '\u00c3' // 'Ã'
                    , '\u00c4' // 'Ä'
                    , '\u00c5' // 'Å'
                    , '\u00c6' // 'Æ'
                    , '\u00c7' // 'Ç'
                    , '\u00c8' // 'È'
                    , '\u00c9' // 'É'
                    , '\u00ca' // 'Ê'
                    , '\u00cb' // 'Ë'
                    , '\u00cc' // 'Ì'
                    , '\u00cd' // 'Í'
                    , '\u00ce' // 'Î'
                    , '\u00cf' // 'Ï'
                    , '\u00d0' // 'Ð'
                    , '\u00d1' // 'Ñ'
                    , '\u00d2' // 'Ò'
                    , '\u00d3' // 'Ó'
                    , '\u00d4' // 'Ô'
                    , '\u00d5' // 'Õ'
                    , '\u00d6' // 'Ö'
                    , '\u00d7' // '×'
                    , '\u00d8' // 'Ø'
                    , '\u00d9' // 'Ù'
                    , '\u00da' // 'Ú'
                    , '\u00db' // 'Û'
                    , '\u00dc' // 'Ü'
                    , '\u00dd' // 'Ý'
                    , '\u00de' // 'Þ'
                    , '\u00df' // 'ß'
                    , '\u00e0' // 'à'
                    , '\u00e1' // 'á'
                    , '\u00e2' // 'â'
                    , '\u00e3' // 'ã'
                    , '\u00e4' // 'ä'
                    , '\u00e5' // 'å'
                    , '\u00e6' // 'æ'
                    , '\u00e7' // 'ç'
                    , '\u00e8' // 'è'
                    , '\u00e9' // 'é'
                    , '\u00ea' // 'ê'
                    , '\u00eb' // 'ë'
                    , '\u00ec' // 'ì'
                    , '\u00ed' // 'í'
                    , '\u00ee' // 'î'
                    , '\u00ef' // 'ï'
                    , '\u00f0' // 'ð'
                    , '\u00f1' // 'ñ'
                    , '\u00f2' // 'ò'
                    , '\u00f3' // 'ó'
                    , '\u00f4' // 'ô'
                    , '\u00f5' // 'õ'
                    , '\u00f6' // 'ö'
                    , '\u00f7' // '÷'
                    , '\u00f8' // 'ø'
                    , '\u00f9' // 'ù'
                    , '\u00fa' // 'ú'
                    , '\u00fb' // 'û'
                    , '\u00fc' // 'ü'
                    , '\u00fd' // 'ý'
                    , '\u00fe' // 'þ'
                    , '\u00ff' // 'ÿ'
                };

            charToBytes_ = new Dictionary<char, byte>()
            {
                { /* '€' */ '\u20ac', 128 },
                { /* '‚' */ '\u201a', 130 },
                { /* 'ƒ' */ '\u0192', 131 },
                { /* '„' */ '\u201e', 132 },
                { /* '…' */ '\u2026', 133 },
                { /* '†' */ '\u2020', 134 },
                { /* '‡' */ '\u2021', 135 },
                { /* 'ˆ' */ '\u02c6', 136 },
                { /* '‰' */ '\u2030', 137 },
                { /* 'Š' */ '\u0160', 138 },
                { /* '‹' */ '\u2039', 139 },
                { /* 'Œ' */ '\u0152', 140 },
                { /* 'Ž' */ '\u017d', 142 },
                { /* '‘' */ '\u2018', 145 },
                { /* '’' */ '\u2019', 146 },
                { /* '“' */ '\u201c', 147 },
                { /* '”' */ '\u201d', 148 },
                { /* '•' */ '\u2022', 149 },
                { /* '–' */ '\u2013', 150 },
                { /* '—' */ '\u2014', 151 },
                { /* '˜' */ '\u02dc', 152 },
                { /* '™' */ '\u2122', 153 },
                { /* 'š' */ '\u0161', 154 },
                { /* '›' */ '\u203a', 155 },
                { /* 'œ' */ '\u0153', 156 },
                { /* 'ž' */ '\u017e', 158 },
                { /* 'Ÿ' */ '\u0178', 159 },
            };
        }
Пример #30
0
        internal static Encoding GetEncodingFromProvider(string encodingName, EncoderFallback enc, DecoderFallback dec)
        {
            if (s_providers == null)
                return null;

            EncodingProvider[] providers = s_providers;
            foreach (EncodingProvider provider in providers)
            {
                Encoding encoding = provider.GetEncoding(encodingName, enc, dec);
                if (encoding != null)
                    return encoding;
            }

            return null;
        }
Пример #31
0
 protected EncodingNLS(int codePage, EncoderFallback enc, DecoderFallback dec)
     : base(codePage, enc, dec)
 {
 }
Пример #32
0
		private MLangCodePageEncoding (SerializationInfo info, StreamingContext context)
		{
			if (info == null)
				throw new ArgumentNullException ("info");

			this.codePage = (int) info.GetValue ("m_codePage", typeof (int));

			try {
				this.isReadOnly = (bool) info.GetValue ("m_isReadOnly", typeof (bool));
				this.encoderFallback = (EncoderFallback) info.GetValue ("encoderFallback", typeof (EncoderFallback));
				this.decoderFallback = (DecoderFallback) info.GetValue ("decoderFallback", typeof (DecoderFallback));
			} catch (SerializationException) {
				// .NET Framework 1.x has no fallbacks
				this.isReadOnly = true;
			}
		}
Пример #33
0
        // GetEncoding should return either valid encoding or null. shouldn't throw any exception except on null name
        public virtual Encoding?GetEncoding(string name, EncoderFallback encoderFallback, DecoderFallback decoderFallback)
        {
            Encoding?enc = GetEncoding(name);

            if (enc != null)
            {
                enc = (Encoding)enc.Clone();
                enc.EncoderFallback = encoderFallback;
                enc.DecoderFallback = decoderFallback;
            }

            return(enc);
        }
Пример #34
0
        public Windows1250Encoding(EncoderFallback encoderFallback, DecoderFallback decoderFallback)
            : base(1250, "Central and Eastern Europe (Windows)", "windows-1250", encoderFallback, decoderFallback)
        {
            byteToChars_ = new char[]
            {
                          '\u0000' // ''
                        , '\u0001' // ''
                        , '\u0002' // ''
                        , '\u0003' // ''
                        , '\u0004' // ''
                        , '\u0005' // ''
                        , '\u0006' // ''
                        , '\u0007' // ''
                        , '\u0008' // ''
                        , '\u0009' // '<TAB>'
                        , '\u000a' // '<LF>'
                        , '\u000b' // ''
                        , '\u000c' // ''
                        , '\u000d' // '<CR>'
                        , '\u000e' // ''
                        , '\u000f' // ''
                        , '\u0010' // ''
                        , '\u0011' // ''
                        , '\u0012' // ''
                        , '\u0013' // ''
                        , '\u0014' // ''
                        , '\u0015' // ''
                        , '\u0016' // ''
                        , '\u0017' // ''
                        , '\u0018' // ''
                        , '\u0019' // ''
                        , '\u001a' // ''
                        , '\u001b' // ''
                        , '\u001c' // ''
                        , '\u001d' // ''
                        , '\u001e' // ''
                        , '\u001f' // ''
                        , '\u0020' // ' '
                        , '\u0021' // '!'
                        , '\u0022' // '"'
                        , '\u0023' // '#'
                        , '\u0024' // '$'
                        , '\u0025' // '%'
                        , '\u0026' // '&'
                        , '\u0027' // '''
                        , '\u0028' // '('
                        , '\u0029' // ')'
                        , '\u002a' // '*'
                        , '\u002b' // '+'
                        , '\u002c' // ','
                        , '\u002d' // '-'
                        , '\u002e' // '.'
                        , '\u002f' // '/'
                        , '\u0030' // '0'
                        , '\u0031' // '1'
                        , '\u0032' // '2'
                        , '\u0033' // '3'
                        , '\u0034' // '4'
                        , '\u0035' // '5'
                        , '\u0036' // '6'
                        , '\u0037' // '7'
                        , '\u0038' // '8'
                        , '\u0039' // '9'
                        , '\u003a' // ':'
                        , '\u003b' // ';'
                        , '\u003c' // '<'
                        , '\u003d' // '='
                        , '\u003e' // '>'
                        , '\u003f' // '?'
                        , '\u0040' // '@'
                        , '\u0041' // 'A'
                        , '\u0042' // 'B'
                        , '\u0043' // 'C'
                        , '\u0044' // 'D'
                        , '\u0045' // 'E'
                        , '\u0046' // 'F'
                        , '\u0047' // 'G'
                        , '\u0048' // 'H'
                        , '\u0049' // 'I'
                        , '\u004a' // 'J'
                        , '\u004b' // 'K'
                        , '\u004c' // 'L'
                        , '\u004d' // 'M'
                        , '\u004e' // 'N'
                        , '\u004f' // 'O'
                        , '\u0050' // 'P'
                        , '\u0051' // 'Q'
                        , '\u0052' // 'R'
                        , '\u0053' // 'S'
                        , '\u0054' // 'T'
                        , '\u0055' // 'U'
                        , '\u0056' // 'V'
                        , '\u0057' // 'W'
                        , '\u0058' // 'X'
                        , '\u0059' // 'Y'
                        , '\u005a' // 'Z'
                        , '\u005b' // '['
                        , '\u005c' // '\'
                        , '\u005d' // ']'
                        , '\u005e' // '^'
                        , '\u005f' // '_'
                        , '\u0060' // '`'
                        , '\u0061' // 'a'
                        , '\u0062' // 'b'
                        , '\u0063' // 'c'
                        , '\u0064' // 'd'
                        , '\u0065' // 'e'
                        , '\u0066' // 'f'
                        , '\u0067' // 'g'
                        , '\u0068' // 'h'
                        , '\u0069' // 'i'
                        , '\u006a' // 'j'
                        , '\u006b' // 'k'
                        , '\u006c' // 'l'
                        , '\u006d' // 'm'
                        , '\u006e' // 'n'
                        , '\u006f' // 'o'
                        , '\u0070' // 'p'
                        , '\u0071' // 'q'
                        , '\u0072' // 'r'
                        , '\u0073' // 's'
                        , '\u0074' // 't'
                        , '\u0075' // 'u'
                        , '\u0076' // 'v'
                        , '\u0077' // 'w'
                        , '\u0078' // 'x'
                        , '\u0079' // 'y'
                        , '\u007a' // 'z'
                        , '\u007b' // '{'
                        , '\u007c' // '|'
                        , '\u007d' // '}'
                        , '\u007e' // '~'
                        , '\u007f' // ''
                        , '\u20ac' // '€'
                        , '\u0081' // ''
                        , '\u201a' // '‚'
                        , '\u0083' // 'ƒ'
                        , '\u201e' // '„'
                        , '\u2026' // '…'
                        , '\u2020' // '†'
                        , '\u2021' // '‡'
                        , '\u0088' // 'ˆ'
                        , '\u2030' // '‰'
                        , '\u0160' // 'Š'
                        , '\u2039' // '‹'
                        , '\u015a' // 'Ś'
                        , '\u0164' // 'Ť'
                        , '\u017d' // 'Ž'
                        , '\u0179' // 'Ź'
                        , '\u0090' // ''
                        , '\u2018' // '‘'
                        , '\u2019' // '’'
                        , '\u201c' // '“'
                        , '\u201d' // '”'
                        , '\u2022' // '•'
                        , '\u2013' // '–'
                        , '\u2014' // '—'
                        , '\u0098' // '˜'
                        , '\u2122' // '™'
                        , '\u0161' // 'š'
                        , '\u203a' // '›'
                        , '\u015b' // 'ś'
                        , '\u0165' // 'ť'
                        , '\u017e' // 'ž'
                        , '\u017a' // 'ź'
                        , '\u00a0' // ' '
                        , '\u02c7' // 'ˇ'
                        , '\u02d8' // '˘'
                        , '\u0141' // 'Ł'
                        , '\u00a4' // '¤'
                        , '\u0104' // 'Ą'
                        , '\u00a6' // '¦'
                        , '\u00a7' // '§'
                        , '\u00a8' // '¨'
                        , '\u00a9' // '©'
                        , '\u015e' // 'Ş'
                        , '\u00ab' // '«'
                        , '\u00ac' // '¬'
                        , '\u00ad' // '­'
                        , '\u00ae' // '®'
                        , '\u017b' // 'Ż'
                        , '\u00b0' // '°'
                        , '\u00b1' // '±'
                        , '\u02db' // '˛'
                        , '\u0142' // 'ł'
                        , '\u00b4' // '´'
                        , '\u00b5' // 'µ'
                        , '\u00b6' // '¶'
                        , '\u00b7' // '·'
                        , '\u00b8' // '¸'
                        , '\u0105' // 'ą'
                        , '\u015f' // 'ş'
                        , '\u00bb' // '»'
                        , '\u013d' // 'Ľ'
                        , '\u02dd' // '˝'
                        , '\u013e' // 'ľ'
                        , '\u017c' // 'ż'
                        , '\u0154' // 'Ŕ'
                        , '\u00c1' // 'Á'
                        , '\u00c2' // 'Â'
                        , '\u0102' // 'Ă'
                        , '\u00c4' // 'Ä'
                        , '\u0139' // 'Ĺ'
                        , '\u0106' // 'Ć'
                        , '\u00c7' // 'Ç'
                        , '\u010c' // 'Č'
                        , '\u00c9' // 'É'
                        , '\u0118' // 'Ę'
                        , '\u00cb' // 'Ë'
                        , '\u011a' // 'Ě'
                        , '\u00cd' // 'Í'
                        , '\u00ce' // 'Î'
                        , '\u010e' // 'Ď'
                        , '\u0110' // 'Đ'
                        , '\u0143' // 'Ń'
                        , '\u0147' // 'Ň'
                        , '\u00d3' // 'Ó'
                        , '\u00d4' // 'Ô'
                        , '\u0150' // 'Ő'
                        , '\u00d6' // 'Ö'
                        , '\u00d7' // '×'
                        , '\u0158' // 'Ř'
                        , '\u016e' // 'Ů'
                        , '\u00da' // 'Ú'
                        , '\u0170' // 'Ű'
                        , '\u00dc' // 'Ü'
                        , '\u00dd' // 'Ý'
                        , '\u0162' // 'Ţ'
                        , '\u00df' // 'ß'
                        , '\u0155' // 'ŕ'
                        , '\u00e1' // 'á'
                        , '\u00e2' // 'â'
                        , '\u0103' // 'ă'
                        , '\u00e4' // 'ä'
                        , '\u013a' // 'ĺ'
                        , '\u0107' // 'ć'
                        , '\u00e7' // 'ç'
                        , '\u010d' // 'č'
                        , '\u00e9' // 'é'
                        , '\u0119' // 'ę'
                        , '\u00eb' // 'ë'
                        , '\u011b' // 'ě'
                        , '\u00ed' // 'í'
                        , '\u00ee' // 'î'
                        , '\u010f' // 'ď'
                        , '\u0111' // 'đ'
                        , '\u0144' // 'ń'
                        , '\u0148' // 'ň'
                        , '\u00f3' // 'ó'
                        , '\u00f4' // 'ô'
                        , '\u0151' // 'ő'
                        , '\u00f6' // 'ö'
                        , '\u00f7' // '÷'
                        , '\u0159' // 'ř'
                        , '\u016f' // 'ů'
                        , '\u00fa' // 'ú'
                        , '\u0171' // 'ű'
                        , '\u00fc' // 'ü'
                        , '\u00fd' // 'ý'
                        , '\u0163' // 'ţ'
                        , '\u02d9' // '˙'
                };

            charToBytes_ = new Dictionary<char, byte>()
            {
                        { /* '€' */ '\u20ac', 128 },
                        { /* '‚' */ '\u201a', 130 },
                        { /* '„' */ '\u201e', 132 },
                        { /* '…' */ '\u2026', 133 },
                        { /* '†' */ '\u2020', 134 },
                        { /* '‡' */ '\u2021', 135 },
                        { /* '‰' */ '\u2030', 137 },
                        { /* 'Š' */ '\u0160', 138 },
                        { /* '‹' */ '\u2039', 139 },
                        { /* 'Ś' */ '\u015a', 140 },
                        { /* 'Ť' */ '\u0164', 141 },
                        { /* 'Ž' */ '\u017d', 142 },
                        { /* 'Ź' */ '\u0179', 143 },
                        { /* '‘' */ '\u2018', 145 },
                        { /* '’' */ '\u2019', 146 },
                        { /* '“' */ '\u201c', 147 },
                        { /* '”' */ '\u201d', 148 },
                        { /* '•' */ '\u2022', 149 },
                        { /* '–' */ '\u2013', 150 },
                        { /* '—' */ '\u2014', 151 },
                        { /* '™' */ '\u2122', 153 },
                        { /* 'š' */ '\u0161', 154 },
                        { /* '›' */ '\u203a', 155 },
                        { /* 'ś' */ '\u015b', 156 },
                        { /* 'ť' */ '\u0165', 157 },
                        { /* 'ž' */ '\u017e', 158 },
                        { /* 'ź' */ '\u017a', 159 },
                        { /* 'ˇ' */ '\u02c7', 161 },
                        { /* '˘' */ '\u02d8', 162 },
                        { /* 'Ł' */ '\u0141', 163 },
                        { /* 'Ą' */ '\u0104', 165 },
                        { /* 'Ş' */ '\u015e', 170 },
                        { /* 'Ż' */ '\u017b', 175 },
                        { /* '˛' */ '\u02db', 178 },
                        { /* 'ł' */ '\u0142', 179 },
                        { /* 'ą' */ '\u0105', 185 },
                        { /* 'ş' */ '\u015f', 186 },
                        { /* 'Ľ' */ '\u013d', 188 },
                        { /* '˝' */ '\u02dd', 189 },
                        { /* 'ľ' */ '\u013e', 190 },
                        { /* 'ż' */ '\u017c', 191 },
                        { /* 'Ŕ' */ '\u0154', 192 },
                        { /* 'Ă' */ '\u0102', 195 },
                        { /* 'Ĺ' */ '\u0139', 197 },
                        { /* 'Ć' */ '\u0106', 198 },
                        { /* 'Č' */ '\u010c', 200 },
                        { /* 'Ę' */ '\u0118', 202 },
                        { /* 'Ě' */ '\u011a', 204 },
                        { /* 'Ď' */ '\u010e', 207 },
                        { /* 'Đ' */ '\u0110', 208 },
                        { /* 'Ń' */ '\u0143', 209 },
                        { /* 'Ň' */ '\u0147', 210 },
                        { /* 'Ő' */ '\u0150', 213 },
                        { /* 'Ř' */ '\u0158', 216 },
                        { /* 'Ů' */ '\u016e', 217 },
                        { /* 'Ű' */ '\u0170', 219 },
                        { /* 'Ţ' */ '\u0162', 222 },
                        { /* 'ŕ' */ '\u0155', 224 },
                        { /* 'ă' */ '\u0103', 227 },
                        { /* 'ĺ' */ '\u013a', 229 },
                        { /* 'ć' */ '\u0107', 230 },
                        { /* 'č' */ '\u010d', 232 },
                        { /* 'ę' */ '\u0119', 234 },
                        { /* 'ě' */ '\u011b', 236 },
                        { /* 'ď' */ '\u010f', 239 },
                        { /* 'đ' */ '\u0111', 240 },
                        { /* 'ń' */ '\u0144', 241 },
                        { /* 'ň' */ '\u0148', 242 },
                        { /* 'ő' */ '\u0151', 245 },
                        { /* 'ř' */ '\u0159', 248 },
                        { /* 'ů' */ '\u016f', 249 },
                        { /* 'ű' */ '\u0171', 251 },
                        { /* 'ţ' */ '\u0163', 254 },
                        { /* '˙' */ '\u02d9', 255 },
            };
        }
Пример #35
0
 internal static Encoding GetEncodingFromProvider(string encodingName, EncoderFallback enc, DecoderFallback dec)
 {
     if (EncodingProvider.s_providers == null)
     {
         return((Encoding)null);
     }
     foreach (EncodingProvider sProvider in EncodingProvider.s_providers)
     {
         Encoding encoding = sProvider.GetEncoding(encodingName, enc, dec);
         if (encoding != null)
         {
             return(encoding);
         }
     }
     return((Encoding)null);
 }
Пример #36
0
        public static Encoding GetEncoding(int codepage,
            EncoderFallback encoderFallback, DecoderFallback decoderFallback)
        {
            // Get the default encoding (which is cached and read only)
            Encoding baseEncoding = GetEncoding(codepage);

            // Clone it and set the fallback
            Encoding fallbackEncoding = (Encoding)baseEncoding.Clone();
            fallbackEncoding.EncoderFallback = encoderFallback;
            fallbackEncoding.DecoderFallback = decoderFallback;

            return fallbackEncoding;
        }
Пример #37
0
 // Default fallback that we'll use.
 internal virtual void SetDefaultFallbacks()
 {
     // For UTF-X encodings, we use a replacement fallback with an "\xFFFD" string,
     // For ASCII we use "?" replacement fallback, etc.
     this.encoderFallback = new InternalEncoderBestFitFallback(this);
     this.decoderFallback = new InternalDecoderBestFitFallback(this);
 }
Пример #38
0
	internal void SetFallbackInternal (EncoderFallback e, DecoderFallback d)
	{
		if (e != null)
			encoder_fallback = e;
		if (d != null)
			decoder_fallback = d;
	}
Пример #39
0
        public static Encoding GetEncoding(String name,
            EncoderFallback encoderFallback, DecoderFallback decoderFallback)
        {
            Encoding baseEncoding = EncodingProvider.GetEncodingFromProvider(name, encoderFallback, decoderFallback);
            if (baseEncoding != null)
                return baseEncoding;

            //
            // NOTE: If you add a new encoding that can be requested by name, be sure to
            // add the corresponding item in EncodingTable.
            // Otherwise, the code below will throw exception when trying to call
            // EncodingTable.GetCodePageFromName().
            //
            return (GetEncoding(EncodingTable.GetCodePageFromName(name), encoderFallback, decoderFallback));
        }
Пример #40
0
 internal void OnDeserializing()
 {
     // intialize the optional Whidbey fields
     encoderFallback = null;
     decoderFallback = null;
     m_isReadOnly    = true;
 }
Пример #41
0
        // This is internal and called by something else,
        public override unsafe int GetCharCount(byte *bytes, int count, DecoderNLS decoder)
        {
            // Just assert, we're called internally so these should be safe, checked already
            Debug.Assert(bytes != null, "[SBCSCodePageEncoding.GetCharCount]bytes is null");
            Debug.Assert(count >= 0, "[SBCSCodePageEncoding.GetCharCount]byteCount is negative");

            CheckMemorySection();

            // See if we have best fit
            bool bUseBestFit = false;

            // Only need decoder fallback buffer if not using default replacement fallback or best fit fallback.
            DecoderReplacementFallback fallback = null;

            if (decoder == null)
            {
                fallback    = DecoderFallback as DecoderReplacementFallback;
                bUseBestFit = DecoderFallback is InternalDecoderBestFitFallback;
            }
            else
            {
                fallback    = decoder.Fallback as DecoderReplacementFallback;
                bUseBestFit = decoder.Fallback is InternalDecoderBestFitFallback;
                Debug.Assert(!decoder.m_throwOnOverflow || !decoder.InternalHasFallbackBuffer ||
                             decoder.FallbackBuffer.Remaining == 0,
                             "[SBCSCodePageEncoding.GetChars]Expected empty fallback buffer at start");
            }

            if (bUseBestFit || (fallback != null && fallback.MaxCharCount == 1))
            {
                // Just return length, SBCS stay the same length because they don't map to surrogate
                // pairs and we don't have a decoder fallback.
                return(count);
            }

            // Might need one of these later
            DecoderFallbackBuffer       fallbackBuffer = null;
            DecoderFallbackBufferHelper fallbackHelper = new DecoderFallbackBufferHelper(fallbackBuffer);

            // Have to do it the hard way.
            // Assume charCount will be == count
            int charCount = count;

            byte[] byteBuffer = new byte[1];

            // Do it our fast way
            byte *byteEnd = bytes + count;

            // Quick loop
            while (bytes < byteEnd)
            {
                // Faster if don't use *bytes++;
                char c;
                c = _mapBytesToUnicode[*bytes];
                bytes++;

                // If unknown we have to do fallback count
                if (c == UNKNOWN_CHAR)
                {
                    // Must have a fallback buffer
                    if (fallbackBuffer == null)
                    {
                        // Need to adjust count so we get real start
                        if (decoder == null)
                        {
                            fallbackBuffer = DecoderFallback.CreateFallbackBuffer();
                        }
                        else
                        {
                            fallbackBuffer = decoder.FallbackBuffer;
                        }

                        fallbackHelper = new DecoderFallbackBufferHelper(fallbackBuffer);

                        fallbackHelper.InternalInitialize(byteEnd - count, null);
                    }

                    // Use fallback buffer
                    byteBuffer[0] = *(bytes - 1);
                    charCount--;                            // We'd already reserved one for *(bytes-1)
                    charCount += fallbackHelper.InternalFallback(byteBuffer, bytes);
                }
            }

            // Fallback buffer must be empty
            Debug.Assert(fallbackBuffer == null || fallbackBuffer.Remaining == 0,
                         "[SBCSEncoding.GetCharCount]Expected Empty fallback buffer at end");

            // Converted sequence is same length as input
            return(charCount);
        }
Пример #42
0
            // Constructor.
#if NET_2_0
            public UTF8Decoder(DecoderFallback fallback)
Пример #43
0
 internal BaseCodePageEncoding(int codepage, int dataCodePage, EncoderFallback enc, DecoderFallback dec)
     : base(codepage, enc, dec)
 {
     // Remember number of code pages that we'll be using the table for.
     dataTableCodePage = dataCodePage;
     LoadCodePageTables();
 }
Пример #44
0
 internal DecoderNLS(EncodingNLS encoding)
 {
     m_encoding = encoding;
     m_fallback = m_encoding.DecoderFallback;
     Reset();
 }
Пример #45
0
        public virtual Encoding GetEncoding(int codepage, EncoderFallback encoderFallback, DecoderFallback decoderFallback)
        {
            Encoding encoding = this.GetEncoding(codepage);

            if (encoding != null)
            {
                encoding = (Encoding)this.GetEncoding(codepage).Clone();
                encoding.EncoderFallback = encoderFallback;
                encoding.DecoderFallback = decoderFallback;
            }
            return(encoding);
        }
Пример #46
0
        // This constructor is needed to allow any sub-classing implementation to provide encoder/decoder fallback objects 
        // because the encoding object is always created as read-only object and don’t allow setting encoder/decoder fallback 
        // after the creation is done. 
        protected Encoding(int codePage, EncoderFallback encoderFallback, DecoderFallback decoderFallback)
        {
            // Validate code page
            if (codePage < 0)
            {
                throw new ArgumentOutOfRangeException("codePage");
            }
            Contract.EndContractBlock();

            // Remember code page
            m_codePage = codePage;

            this.encoderFallback = encoderFallback ?? new InternalEncoderBestFitFallback(this);
            this.decoderFallback = decoderFallback ?? new InternalDecoderBestFitFallback(this);
        }
Пример #47
0
 // Get a hash code for this instance.
 public override int GetHashCode()
 {
     return(DecoderFallback.GetHashCode() << 24 + EncoderFallback.GetHashCode() << 16 + codePage);
 }
Пример #48
0
        public static Encoding GetEncoding(int codepage,
            EncoderFallback encoderFallback, DecoderFallback decoderFallback)
        {
            Encoding baseEncoding = EncodingProvider.GetEncodingFromProvider(codepage, encoderFallback, decoderFallback);

            if (baseEncoding != null)
                return baseEncoding;

            // Get the default encoding (which is cached and read only)
            baseEncoding = GetEncoding(codepage);

            // Clone it and set the fallback
            Encoding fallbackEncoding = (Encoding)baseEncoding.Clone();
            fallbackEncoding.EncoderFallback = encoderFallback;
            fallbackEncoding.DecoderFallback = decoderFallback;

            return fallbackEncoding;
        }
Пример #49
0
 /// <summary>Returns the encoding associated with the specified code page name. Parameters specify an error handler for characters that cannot be encoded and byte sequences that cannot be decoded.</summary><returns>The encoding that is associated with the specified code page.</returns><param name="name">The code page name of the preferred encoding. Any value returned by the <see cref="P:System.Text.Encoding.WebName" /> property is valid. Possible values are listed in the Name column of the table that appears in the <see cref="T:System.Text.Encoding" /> class topic.</param><param name="encoderFallback">An object that provides an error-handling procedure when a character cannot be encoded with the current encoding. </param><param name="decoderFallback">An object that provides an error-handling procedure when a byte sequence cannot be decoded with the current encoding. </param><exception cref="T:System.ArgumentException"><paramref name="name" /> is not a valid code page name.-or- The code page indicated by <paramref name="name" /> is not supported by the underlying platform. </exception><filterpriority>1</filterpriority>
 public static Encoding GetEncoding(string name, EncoderFallback encoderFallback, DecoderFallback decoderFallback)
 {
     throw new NotImplementedException();
 }
Пример #50
0
 protected EncodingNLS(int codePage, EncoderFallback enc, DecoderFallback dec)
     : base(codePage, enc, dec)
 {
 }
Пример #51
0
        internal static Encoding GetEncodingFromProvider(string encodingName, EncoderFallback enc, DecoderFallback dec)
        {
            if (s_providers == null)
            {
                return(null);
            }

            EncodingProvider[] providers = s_providers;
            foreach (EncodingProvider provider in providers)
            {
                Encoding encoding = provider.GetEncoding(encodingName, enc, dec);
                if (encoding != null)
                {
                    return(encoding);
                }
            }

            return(null);
        }
Пример #52
0
        public override unsafe int GetChars(byte *bytes, int byteCount,
                                            char *chars, int charCount, DecoderNLS decoder)
        {
            // Just need to ASSERT, this is called by something else internal that checked parameters already
            Debug.Assert(bytes != null, "[SBCSCodePageEncoding.GetChars]bytes is null");
            Debug.Assert(byteCount >= 0, "[SBCSCodePageEncoding.GetChars]byteCount is negative");
            Debug.Assert(chars != null, "[SBCSCodePageEncoding.GetChars]chars is null");
            Debug.Assert(charCount >= 0, "[SBCSCodePageEncoding.GetChars]charCount is negative");

            CheckMemorySection();

            // See if we have best fit
            bool bUseBestFit = false;

            // Do it fast way if using ? replacement or best fit fallbacks
            byte *byteEnd   = bytes + byteCount;
            byte *byteStart = bytes;
            char *charStart = chars;

            // Only need decoder fallback buffer if not using default replacement fallback or best fit fallback.
            DecoderReplacementFallback fallback = null;

            if (decoder == null)
            {
                fallback    = DecoderFallback as DecoderReplacementFallback;
                bUseBestFit = DecoderFallback is InternalDecoderBestFitFallback;
            }
            else
            {
                fallback    = decoder.Fallback as DecoderReplacementFallback;
                bUseBestFit = decoder.Fallback is InternalDecoderBestFitFallback;
                Debug.Assert(!decoder.m_throwOnOverflow || !decoder.InternalHasFallbackBuffer ||
                             decoder.FallbackBuffer.Remaining == 0,
                             "[SBCSCodePageEncoding.GetChars]Expected empty fallback buffer at start");
            }

            if (bUseBestFit || (fallback != null && fallback.MaxCharCount == 1))
            {
                // Try it the fast way
                char replacementChar;
                if (fallback == null)
                {
                    replacementChar = '?';  // Best fit always has ? for fallback for SBCS
                }
                else
                {
                    replacementChar = fallback.DefaultString[0];
                }

                // Need byteCount chars, otherwise too small buffer
                if (charCount < byteCount)
                {
                    // Need at least 1 output byte, throw if must throw
                    ThrowCharsOverflow(decoder, charCount < 1);

                    // Not throwing, use what we can
                    byteEnd = bytes + charCount;
                }

                // Quick loop, just do '?' replacement because we don't have fallbacks for decodings.
                while (bytes < byteEnd)
                {
                    char c;
                    if (bUseBestFit)
                    {
                        if (arrayBytesBestFit == null)
                        {
                            ReadBestFitTable();
                        }
                        c = arrayBytesBestFit[*bytes];
                    }
                    else
                    {
                        c = _mapBytesToUnicode[*bytes];
                    }
                    bytes++;

                    if (c == UNKNOWN_CHAR)
                    {
                        // This is an invalid byte in the ASCII encoding.
                        *chars = replacementChar;
                    }
                    else
                    {
                        *chars = c;
                    }
                    chars++;
                }

                // bytes & chars used are the same
                if (decoder != null)
                {
                    decoder.m_bytesUsed = (int)(bytes - byteStart);
                }
                return((int)(chars - charStart));
            }

            // Slower way's going to need a fallback buffer
            DecoderFallbackBuffer fallbackBuffer = null;

            byte[] byteBuffer = new byte[1];
            char * charEnd    = chars + charCount;

            DecoderFallbackBufferHelper fallbackHelper = new DecoderFallbackBufferHelper(null);

            // Not quite so fast loop
            while (bytes < byteEnd)
            {
                // Faster if don't use *bytes++;
                char c = _mapBytesToUnicode[*bytes];
                bytes++;

                // See if it was unknown
                if (c == UNKNOWN_CHAR)
                {
                    // Make sure we have a fallback buffer
                    if (fallbackBuffer == null)
                    {
                        if (decoder == null)
                        {
                            fallbackBuffer = DecoderFallback.CreateFallbackBuffer();
                        }
                        else
                        {
                            fallbackBuffer = decoder.FallbackBuffer;
                        }

                        fallbackHelper = new DecoderFallbackBufferHelper(fallbackBuffer);

                        fallbackHelper.InternalInitialize(byteEnd - byteCount, charEnd);
                    }

                    // Use fallback buffer
                    Debug.Assert(bytes > byteStart,
                                 "[SBCSCodePageEncoding.GetChars]Expected bytes to have advanced already (unknown byte)");
                    byteBuffer[0] = *(bytes - 1);
                    // Fallback adds fallback to chars, but doesn't increment chars unless the whole thing fits.
                    if (!fallbackHelper.InternalFallback(byteBuffer, bytes, ref chars))
                    {
                        // May or may not throw, but we didn't get this byte
                        bytes--;                                            // unused byte
                        fallbackHelper.InternalReset();                     // Didn't fall this back
                        ThrowCharsOverflow(decoder, bytes == byteStart);    // throw?
                        break;                                              // don't throw, but stop loop
                    }
                }
                else
                {
                    // Make sure we have buffer space
                    if (chars >= charEnd)
                    {
                        Debug.Assert(bytes > byteStart,
                                     "[SBCSCodePageEncoding.GetChars]Expected bytes to have advanced already (known byte)");
                        bytes--;                                            // unused byte
                        ThrowCharsOverflow(decoder, bytes == byteStart);    // throw?
                        break;                                              // don't throw, but stop loop
                    }

                    *(chars) = c;
                    chars++;
                }
            }

            // Might have had decoder fallback stuff.
            if (decoder != null)
            {
                decoder.m_bytesUsed = (int)(bytes - byteStart);
            }

            // Expect Empty fallback buffer for GetChars
            Debug.Assert(fallbackBuffer == null || fallbackBuffer.Remaining == 0,
                         "[SBCSEncoding.GetChars]Expected Empty fallback buffer at end");

            return((int)(chars - charStart));
        }
Пример #53
0
        public virtual Encoding GetEncoding(int codepage, EncoderFallback encoderFallback, DecoderFallback decoderFallback)
        {
            Encoding enc = GetEncoding(codepage);

            if (enc != null)
            {
                enc = (Encoding)GetEncoding(codepage).Clone();
                enc.EncoderFallback = encoderFallback;
                enc.DecoderFallback = decoderFallback;
            }

            return(enc);
        }
Пример #54
0
 [System.Security.SecurityCritical]  // auto-generated
 internal DBCSCodePageEncoding(int codePage, int dataCodePage, EncoderFallback enc, DecoderFallback dec) : base(codePage, dataCodePage, enc, dec)
 {
 }
Пример #55
0
        int GetChars(byte[] bytes, int byteIndex, int byteCount,
                     char[] chars, int charIndex,
                     ref DecoderFallbackBuffer buffer)
        {
            if (bytes == null)
            {
                throw new ArgumentNullException("bytes");
            }
            if (chars == null)
            {
                throw new ArgumentNullException("chars");
            }
            if (byteIndex < 0 || byteIndex > bytes.Length)
            {
                throw new ArgumentOutOfRangeException("byteIndex", _("ArgRange_Array"));
            }
            if (byteCount < 0 || byteCount > (bytes.Length - byteIndex))
            {
                throw new ArgumentOutOfRangeException("byteCount", _("ArgRange_Array"));
            }
            if (charIndex < 0 || charIndex > chars.Length)
            {
                throw new ArgumentOutOfRangeException("charIndex", _("ArgRange_Array"));
            }

            if ((chars.Length - charIndex) < byteCount)
            {
                throw new ArgumentException(_("Arg_InsufficientSpace"));
            }

            int count = byteCount;

            while (count-- > 0)
            {
                char c = (char)bytes [byteIndex++];
                if (c < '\x80')
                {
                    chars [charIndex++] = c;
                }
                else
                {
                    if (buffer == null)
                    {
                        buffer = DecoderFallback.CreateFallbackBuffer();
                    }
                    var thisByte = new byte[] { bytes [byteIndex - 1] };
                    buffer.Fallback(thisByte, 0);
                    while (buffer.Remaining > 0)
                    {
                        if (charIndex < chars.Length)
                        {
                            chars [charIndex++] = buffer.GetNextChar();
                            continue;
                        }
                        throw new ArgumentException(
                                  "The output char buffer is too small to contain the " +
                                  "decoded characters.");
                    }
                }
            }
            return(byteCount);
        }