當前位置: 首頁>>代碼示例>>C#>>正文


C# Text.EncoderFallback類代碼示例

本文整理匯總了C#中System.Text.EncoderFallback的典型用法代碼示例。如果您正苦於以下問題:C# EncoderFallback類的具體用法?C# EncoderFallback怎麽用?C# EncoderFallback使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


EncoderFallback類屬於System.Text命名空間,在下文中一共展示了EncoderFallback類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: CodePageEncoding

 protected CodePageEncoding(int codePage, string name, string webName, EncoderFallback encoderFallback, DecoderFallback decoderFallback)
     : base(codePage, encoderFallback, decoderFallback)
 {
     codePage_ = codePage;
     encodingName_ = name;
     webName_ = webName;
 }
開發者ID:springcomp,項目名稱:TextPad,代碼行數:7,代碼來源:CodePageEncoding.cs

示例2: InternalGetByteCount

	// Internal version of "GetByteCount" which can handle a rolling
	// state between multiple calls to this method.
	private static int InternalGetByteCount (char[] chars, int index, int count, EncoderFallback fallback, ref char leftOver, bool flush)
	{
		// Validate the parameters.
		if (chars == null) {
			throw new ArgumentNullException ("chars");
		}
		if (index < 0 || index > chars.Length) {
			throw new ArgumentOutOfRangeException ("index", _("ArgRange_Array"));
		}
		if (count < 0 || count > (chars.Length - index)) {
			throw new ArgumentOutOfRangeException ("count", _("ArgRange_Array"));
		}

		if (index == chars.Length) {
			if (flush && leftOver != '\0') {
				// Flush the left-over surrogate pair start.
				leftOver = '\0';
				return 3;
			}
			return 0;
		}

		unsafe {
			fixed (char* cptr = chars) {
				return InternalGetByteCount (cptr + index, count, fallback, ref leftOver, flush);
			}
		}
	}
開發者ID:calumjiao,項目名稱:Mono-Class-Libraries,代碼行數:30,代碼來源:UTF8Encoding.cs

示例3: CodePageEncoding

        // 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;
            }
        }
開發者ID:kouvel,項目名稱:coreclr,代碼行數:32,代碼來源:CodePageEncoding.cs

示例4: BaseCodePageEncoding

 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();
 }
開發者ID:gitter-badger,項目名稱:corefx,代碼行數:7,代碼來源:BaseCodePageEncoding.cs

示例5: EncoderNLSSurrogate

 internal EncoderNLSSurrogate(SerializationInfo info, StreamingContext context)
 {
     if (info == null)
     {
         throw new ArgumentNullException(nameof(info));
     }
     _encoding = (Encoding)info.GetValue(EncodingKey, typeof(Encoding));
     _fallback = (EncoderFallback)info.GetValue(DecoderFallbackKey, typeof(EncoderFallback));
     _charLeftOver = (char)info.GetValue(CharLeftOverKey, typeof(char));
 }
開發者ID:naamunds,項目名稱:corefx,代碼行數:10,代碼來源:EncoderNLS.cs

示例6: GetEncoding

        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;
        }
開發者ID:tijoytom,項目名稱:corert,代碼行數:12,代碼來源:EncodingProvider.cs

示例7: MLangCodePageEncoding

 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;
     }
 }
開發者ID:pritesh-mandowara-sp,項目名稱:DecompliedDotNetLibraries,代碼行數:19,代碼來源:MLangCodePageEncoding.cs

示例8: MLangCodePageEncoding

        // 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;
            }
        }
開發者ID:gbarnett,項目名稱:shared-source-cli-2.0,代碼行數:25,代碼來源:mlangcodepageencoding.cs

示例9: DeserializeEncoding

        // 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();
            }
        }
開發者ID:enavro,項目名稱:coreclr,代碼行數:39,代碼來源:Encoding.cs

示例10: GetEncoding

	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;
	}
開發者ID:csulmone,項目名稱:mono,代碼行數:14,代碼來源:Encoding.cs

示例11: SetFallbackInternal

	internal void SetFallbackInternal (EncoderFallback e, DecoderFallback d)
	{
		if (e != null)
			encoder_fallback = e;
		if (d != null)
			decoder_fallback = d;
	}
開發者ID:csulmone,項目名稱:mono,代碼行數:7,代碼來源:Encoding.cs

示例12: GetEncoding

        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;
        }
開發者ID:afrog33k,項目名稱:csnative,代碼行數:13,代碼來源:Encoding.cs

示例13: InternalGetBytes

	private unsafe static int InternalGetBytes (char* chars, int count, byte* bytes, int bcount, EncoderFallback fallback, ref EncoderFallbackBuffer buffer, ref char leftOver, bool flush)
	{
		char* end = chars + count;
		char* start = chars;
		byte* start_bytes = bytes;
		byte* end_bytes = bytes + bcount;
		while (chars < end) {
			if (leftOver == 0) {
				for (; chars < end; chars++) {
					int ch = *chars;
					if (ch < '\x80') {
						if (bytes >= end_bytes)
							goto fail_no_space;
						*bytes++ = (byte)ch;
					} else if (ch < '\x800') {
						if (bytes + 1 >= end_bytes)
							goto fail_no_space;
						bytes [0] = (byte) (0xC0 | (ch >> 6));
						bytes [1] = (byte) (0x80 | (ch & 0x3F));
						bytes += 2;
					} else if (ch < '\uD800' || ch > '\uDFFF') {
						if (bytes + 2 >= end_bytes)
							goto fail_no_space;
						bytes [0] = (byte) (0xE0 | (ch >> 12));
						bytes [1] = (byte) (0x80 | ((ch >> 6) & 0x3F));
						bytes [2] = (byte) (0x80 | (ch & 0x3F));
						bytes += 3;
					} else if (ch <= '\uDBFF') {
						// This is a surrogate char, exit the inner loop.
						leftOver = *chars;
						chars++;
						break;
					} else {
						// We have a surrogate tail without 
						// leading surrogate. In NET_2_0 it
						// uses fallback. In NET_1_1 we output
						// wrong surrogate.
						char [] fallback_chars = GetFallbackChars (chars, start, fallback, ref buffer); 
						char dummy = '\0';
						if (bytes + InternalGetByteCount (fallback_chars, 0, fallback_chars.Length, fallback, ref dummy, true) > end_bytes)
							goto fail_no_space;
						fixed (char *fb_chars = fallback_chars) {
							bytes += InternalGetBytes (fb_chars, fallback_chars.Length, bytes, bcount - (int) (bytes - start_bytes), fallback, ref buffer, ref dummy, true);
						}

						leftOver = '\0';
					}
				}
			} else {
				if (*chars >= '\uDC00' && *chars <= '\uDFFF') {
					// We have a correct surrogate pair.
					int ch = 0x10000 + (int) *chars - 0xDC00 + (((int) leftOver - 0xD800) << 10);
					if (bytes + 3 >= end_bytes)
						goto fail_no_space;
					bytes [0] = (byte) (0xF0 | (ch >> 18));
					bytes [1] = (byte) (0x80 | ((ch >> 12) & 0x3F));
					bytes [2] = (byte) (0x80 | ((ch >> 6) & 0x3F));
					bytes [3] = (byte) (0x80 | (ch & 0x3F));
					bytes += 4;
					chars++;
				} else {
					// We have a surrogate start followed by a
					// regular character.  Technically, this is
					// invalid, but we have to do something.
					// We write out the surrogate start and then
					// re-visit the current character again.
					char [] fallback_chars = GetFallbackChars (chars, start, fallback, ref buffer); 
					char dummy = '\0';
					if (bytes + InternalGetByteCount (fallback_chars, 0, fallback_chars.Length, fallback, ref dummy, true) > end_bytes)
						goto fail_no_space;
					fixed (char *fb_chars = fallback_chars) {
						InternalGetBytes (fb_chars, fallback_chars.Length, bytes, bcount - (int) (bytes - start_bytes), fallback, ref buffer, ref dummy, true);
					}

					leftOver = '\0';
				}
				leftOver = '\0';
			}
		}
		if (flush) {
			// Flush the left-over surrogate pair start.
			if (leftOver != '\0') {
				int ch = leftOver;
				if (bytes + 2 < end_bytes) {
					bytes [0] = (byte) (0xE0 | (ch >> 12));
					bytes [1] = (byte) (0x80 | ((ch >> 6) & 0x3F));
					bytes [2] = (byte) (0x80 | (ch & 0x3F));
					bytes += 3;
				} else {
					goto fail_no_space;
				}
				leftOver = '\0';
			}
		}
		return (int)(bytes - (end_bytes - bcount));
fail_no_space:
		throw new ArgumentException ("Insufficient Space", "bytes");
	}
開發者ID:calumjiao,項目名稱:Mono-Class-Libraries,代碼行數:98,代碼來源:UTF8Encoding.cs

示例14: SetEncoderFallback

 public void SetEncoderFallback(EncoderFallback fallback) {
     throw new NotImplementedException();
 }
開發者ID:CforED,項目名稱:Node.js-Tools-for-Visual-Studio,代碼行數:3,代碼來源:MockTextDocument.cs

示例15: GetEncoding

        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;
        }
開發者ID:krytarowski,項目名稱:corert,代碼行數:18,代碼來源:Encoding.cs


注:本文中的System.Text.EncoderFallback類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。