当前位置: 首页>>代码示例>>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;未经允许,请勿转载。