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


C# Text.Decoder類代碼示例

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


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

示例1: BinaryReader

        public BinaryReader(Stream input, Encoding encoding, bool leaveOpen) {
            if (input==null) {
                throw new ArgumentNullException(nameof(input));
            }
            if (encoding==null) {
                throw new ArgumentNullException(nameof(encoding));
            }
            if (!input.CanRead)
                throw new ArgumentException(Environment.GetResourceString("Argument_StreamNotReadable"));
            Contract.EndContractBlock();
            m_stream = input;
            m_decoder = encoding.GetDecoder();
            m_maxCharsSize = encoding.GetMaxCharCount(MaxCharBytesSize);
            int minBufferSize = encoding.GetMaxByteCount(1);  // max bytes per one char
            if (minBufferSize < 16) 
                minBufferSize = 16;
            m_buffer = new byte[minBufferSize];
            // m_charBuffer and m_charBytes will be left null.

            // For Encodings that always use 2 bytes per char (or more), 
            // special case them here to make Read() & Peek() faster.
            m_2BytesPerChar = encoding is UnicodeEncoding;
            // check if BinaryReader is based on MemoryStream, and keep this for it's life
            // we cannot use "as" operator, since derived classes are not allowed
            m_isMemoryStream = (m_stream.GetType() == typeof(MemoryStream));
            m_leaveOpen = leaveOpen;

            Contract.Assert(m_decoder!=null, "[BinaryReader.ctor]m_decoder!=null");
        }
開發者ID:JonHanna,項目名稱:coreclr,代碼行數:29,代碼來源:BinaryReader.cs

示例2: BinaryReader

 public BinaryReader(Stream input, Encoding encoding)
 {
     if (input == null)
     {
         throw new ArgumentNullException("input");
     }
     if (encoding == null)
     {
         throw new ArgumentNullException("encoding");
     }
     if (!input.CanRead)
     {
         throw new ArgumentException(Environment.GetResourceString("Argument_StreamNotReadable"));
     }
     this.m_stream = input;
     this.m_decoder = encoding.GetDecoder();
     this.m_maxCharsSize = encoding.GetMaxCharCount(0x80);
     int maxByteCount = encoding.GetMaxByteCount(1);
     if (maxByteCount < 0x10)
     {
         maxByteCount = 0x10;
     }
     this.m_buffer = new byte[maxByteCount];
     this.m_charBuffer = null;
     this.m_charBytes = null;
     this.m_2BytesPerChar = encoding is UnicodeEncoding;
     this.m_isMemoryStream = this.m_stream.GetType() == typeof(MemoryStream);
 }
開發者ID:pritesh-mandowara-sp,項目名稱:DecompliedDotNetLibraries,代碼行數:28,代碼來源:BinaryReader.cs

示例3: CFile

 /// <summary>
 /// Create new C file access
 /// </summary>
 public CFile(Stream stream, Encoding encoding = null)
 {
     this._Stream = stream;
     EOF = _Stream == null;
     this._Encoding = encoding ?? Encoding.GetEncoding("Windows-1252");
     this._Decoder = _Encoding.GetDecoder();
 }
開發者ID:thenuts,項目名稱:SwissEphNet,代碼行數:10,代碼來源:CFile.cs

示例4: EndianReader

        public EndianReader(Stream input, Endianness endianess, Encoding encoding, bool leaveOpen)
        {
            if (input == null)
            {
                throw new ArgumentNullException(nameof(input));
            }
            if (encoding == null)
            {
                throw new ArgumentNullException(nameof(encoding));
            }
            if (!input.CanRead)
                throw new ArgumentException("Can't read from the output stream", nameof(input));
            Contract.EndContractBlock();

            BaseStream = input;
            decoder = encoding.GetDecoder();
            maxCharsSize = encoding.GetMaxCharCount(MaxCharBytesSize);
            var minBufferSize = encoding.GetMaxByteCount(1);  // max bytes per one char
            if (minBufferSize < 16)
                minBufferSize = 16;
            buffer = new byte[minBufferSize];
            // m_charBuffer and m_charBytes will be left null.

            // For Encodings that always use 2 bytes per char (or more), 
            // special case them here to make Read() & Peek() faster.
            use2BytesPerChar = encoding is UnicodeEncoding;
            this.leaveOpen = leaveOpen;

            Endianness = endianess;
            resolvedEndianess = EndianessHelper.Resolve(endianess);

            Contract.Assert(decoder != null, "[EndianReader.ctor]m_decoder!=null");
        }
開發者ID:vbfox,項目名稱:U2FExperiments,代碼行數:33,代碼來源:EndianReader.cs

示例5: HttpRequestStreamReader

        public HttpRequestStreamReader(Stream stream, Encoding encoding, int bufferSize)
        {
            if (stream == null)
            {
                throw new ArgumentNullException(nameof(stream));
            }

            if (!stream.CanRead)
            {
                throw new ArgumentException(Resources.HttpRequestStreamReader_StreamNotReadable, nameof(stream));
            }

            if (encoding == null)
            {
                throw new ArgumentNullException(nameof(encoding));
            }

            _stream = stream;
            _encoding = encoding;
            _decoder = encoding.GetDecoder();

            if (bufferSize < MinBufferSize)
            {
                bufferSize = MinBufferSize;
            }

            _byteBufferSize = bufferSize;
            _byteBuffer = new byte[bufferSize];
            var maxCharsPerBuffer = encoding.GetMaxCharCount(bufferSize);
            _charBuffer = new char[maxCharsPerBuffer];
        }
開發者ID:phinq19,項目名稱:git_example,代碼行數:31,代碼來源:HttpRequestStreamReader.cs

示例6: Main

 static void Main(string[] args)
 {
     //第一個參數是第三方平台
     //第二個參數是平台賬號信息,若此處不設置Account,則需要在策略代碼中設置默認值
     var decoder = new Decoder(Platform.RuoKuai, new Account
     {
         SoftId = 0, // 軟件ID(此ID需要注冊開發者賬號才可獲得)
         TypeId = 0, // 驗證碼類型(四位字符或其他類型的驗證碼,根據各平台設置不同值)
         SoftKey = null, //軟件Key (此Key也需要注冊開發者賬號才可獲得)
         UserName = null, //賬號(此賬號為打碼平台的普通用戶賬號,開發者賬號不能進行圖片識別)
         Password = null //密碼
     });
     decoder.OnStart += (s, e) =>
     {
         Console.WriteLine("驗證碼("+e.FilePath+")識別啟動……");
     };
     decoder.OnCompleted += (s, e) =>
     {
         Console.WriteLine("驗證碼(" + e.FilePath + ")識別完成:" + e.Code + ",耗時:" + (e.Milliseconds/1000) + "秒,線程ID:"+e.ThreadId);
     };
     decoder.OnError += (s, e) =>
     {
         Console.WriteLine("驗證碼識別出錯:" + e.Exception.Message);
     };
     for (var i = 1; i <= 3; i++)
     {
         decoder.Decode("c:\\checkcode"+i+".png");
     }
     Console.ReadKey();
 }
開發者ID:coldicelion,項目名稱:Captcha-Recognizer,代碼行數:30,代碼來源:Program.cs

示例7: EndianBinaryReader

        /// <summary>
        /// Constructs a new binary reader with the given bit converter, reading
        /// to the given stream, using the given encoding.
        /// </summary>
        /// <param name="bitConverter">Converter to use when reading data</param>
        /// <param name="stream">Stream to read data from</param>
        /// <param name="encoding">Encoding to use when reading character data</param>
        public EndianBinaryReader(EndianBitConverter bitConverter, Stream stream, Encoding encoding)
        {
            if (bitConverter == null)
            {
                throw new ArgumentNullException("bitConverter");
            }
            if (stream == null)
            {
                throw new ArgumentNullException("stream");
            }
            if (encoding == null)
            {
                throw new ArgumentNullException("encoding");
            }
            if (!stream.CanRead)
            {
                throw new ArgumentException("Stream isn't writable", "stream");
            }
            this.stream = stream;
            this.bitConverter = bitConverter;
            this.encoding = encoding;
            this.decoder = encoding.GetDecoder();
            this.minBytesPerChar = 1;

            if (encoding is UnicodeEncoding)
            {
                minBytesPerChar = 2;
            }
        }
開發者ID:cornelius90,項目名稱:InnovatorAdmin,代碼行數:36,代碼來源:EndianBinaryReader.cs

示例8: ContentReader

 public ContentReader(Stream stream, long length, Encoding encoding = null) {
     _stream = stream;
     _length = length;
     if (encoding != null) {
         _decoder = encoding.GetDecoder();
     }
 }
開發者ID:roomaroo,項目名稱:coapp.powershell,代碼行數:7,代碼來源:ContentReader.cs

示例9: StaticUtils

        static StaticUtils()
        {
            asciiDecoder = Encoding.ASCII.GetDecoder();

            utf8Encoder = Encoding.UTF8.GetEncoder();
            utf8Decoder = Encoding.UTF8.GetDecoder();
        }
開發者ID:SayHalou,項目名稱:ospy,代碼行數:7,代碼來源:Util.cs

示例10: EndianBinaryReader

 public EndianBinaryReader(EndianBitConverter bitConverter, Stream stream, System.Text.Encoding encoding)
 {
     this.disposed = false;
     this.buffer = new byte[0x10];
     this.charBuffer = new char[1];
     if (bitConverter == null)
     {
         throw new ArgumentNullException("bitConverter");
     }
     if (stream == null)
     {
         throw new ArgumentNullException("stream");
     }
     if (encoding == null)
     {
         throw new ArgumentNullException("encoding");
     }
     if (!stream.CanRead)
     {
         throw new ArgumentException("Stream isn't writable", "stream");
     }
     this.stream = stream;
     this.bitConverter = bitConverter;
     this.encoding = encoding;
     this.decoder = encoding.GetDecoder();
     this.minBytesPerChar = 1;
     if (encoding is UnicodeEncoding)
     {
         this.minBytesPerChar = 2;
     }
 }
開發者ID:BGCX261,項目名稱:znqq-svn-to-git,代碼行數:31,代碼來源:EndianBinaryReader.cs

示例11: XmlParser

 /// <summary>
 /// コンストラクタです。
 /// </summary>
 public XmlParser(Stream stream)
 {
     this.stream = stream;
     this.element = this.name = this.data = "";
     this.attr = new Hashtable();
     this.dec = Encoding.Default.GetDecoder();
     this.letter = false;
 }
開發者ID:yuta1011tokyo,項目名稱:Liplis-Windows,代碼行數:11,代碼來源:XmlParser.cs

示例12: UTF8SanitizerStream

 public UTF8SanitizerStream(string pattern, string substitute, Stream output)
 {
     _pattern = pattern;
     _substitute = substitute;
     _output = output;
     _decoder = Encoding.UTF8.GetDecoder();
     _buffer = String.Empty;
 }
開發者ID:johnnyoshika,項目名稱:coldfusion-rest-post-process,代碼行數:8,代碼來源:UTF8SanitizerStream.cs

示例13: PositionedStreamReader

 public PositionedStreamReader(Stream stream, Encoding encoding)
 {
     this.stream = stream;
     this.encoding = encoding;
     decoder = encoding.GetDecoder();
     bufferpos = 0;
     readPosition = 0;
 }
開發者ID:CodeDevLab,項目名稱:TS3AudioBot,代碼行數:8,代碼來源:PositionedStreamReader.cs

示例14: ReadATTRIBUTEWORD

 /// <summary>
 /// Reads an ATTRIBUTEWORD from the byte buffer.
 /// </summary>
 /// <param name="buffer">buffer containing serialized data</param>
 /// <param name="offset">reference to an offset variable; upon entry offset 
 /// reflects the position within the buffer where reading should begin. 
 /// Upon success the offset will be incremented by the number of bytes that are used.</param>
 /// <param name="coder">Decoder used to translate byte data to character data</param>
 /// <returns>an ATTRIBUTEWORD value taken from the buffer</returns>
 public static string ReadATTRIBUTEWORD(byte[] buffer, ref int offset, Decoder coder)
 {
     #if DEBUG
     if (buffer == null) throw new ArgumentNullException("buffer");
     if (offset < 0 || offset > buffer.Length - 1) throw new BadLwesDataException(String.Concat("Expected ATTRIBUTEWORD at offset ", offset));
     #endif
     return ReadStringWithByteLengthPrefix(buffer, ref offset, coder);
 }
開發者ID:lwes,項目名稱:lwes-dotnet,代碼行數:17,代碼來源:LwesSerializer.cs

示例15: RequestState

 //bool disposed;
 public RequestState()
 {
     BufferRead = new byte[BufferSize];
     RequestData = new StringBuilder(String.Empty);
     Request = null;
     ResponseStream = null;
     StreamDecode = Encoding.UTF8.GetDecoder();
 }
開發者ID:cripperz,項目名稱:proxyscrape,代碼行數:9,代碼來源:RequestState.cs


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