当前位置: 首页>>代码示例>>C#>>正文


C# Encoding.GetEncoder方法代码示例

本文整理汇总了C#中System.Text.Encoding.GetEncoder方法的典型用法代码示例。如果您正苦于以下问题:C# Encoding.GetEncoder方法的具体用法?C# Encoding.GetEncoder怎么用?C# Encoding.GetEncoder使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Text.Encoding的用法示例。


在下文中一共展示了Encoding.GetEncoder方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: HttpResponseStreamWriter

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

            if (!stream.CanWrite)
            {
                throw new ArgumentException(Resources.HttpResponseStreamWriter_StreamNotWritable, nameof(stream));
            }

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

            _stream = stream;
            Encoding = encoding;
            _charBufferSize = bufferSize;

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

            _encoder = encoding.GetEncoder();
            _byteBuffer = new byte[encoding.GetMaxByteCount(bufferSize)];
            _charBuffer = new char[bufferSize];
        }
开发者ID:phinq19,项目名称:git_example,代码行数:30,代码来源:HttpResponseStreamWriter.cs

示例2: BinaryWriter

 // Protected default constructor that sets the output stream
 // to a null stream (a bit bucket).
 protected BinaryWriter()
 {
     OutStream = Stream.Null;
     _buffer = new byte[16];
     _encoding = EncodingCache.UTF8NoBOM;
     _encoder = _encoding.GetEncoder();
 }
开发者ID:kouvel,项目名称:coreclr,代码行数:9,代码来源:BinaryWriter.cs

示例3: BinaryWriter

 // Protected default constructor that sets the output stream
 // to a null stream (a bit bucket).
 protected BinaryWriter()
 {
     OutStream = Stream.Null;
     _buffer = new byte[16];
     _encoding = new UTF8Encoding(false, true);
     _encoder = _encoding.GetEncoder();
 }
开发者ID:Numpsy,项目名称:mono,代码行数:9,代码来源:binarywriter.cs

示例4: EndianWriter

 // Protected default constructor that sets the output stream
 // to a null stream (a bit bucket).
 protected EndianWriter()
 {
     OutStream = Stream.Null;
     buffer = new byte[16];
     Encoding = new UTF8Encoding(false, true);
     encoder = Encoding.GetEncoder();
 }
开发者ID:vbfox,项目名称:U2FExperiments,代码行数:9,代码来源:EndianWriter.cs

示例5: HttpResponseStreamWriter

 public HttpResponseStreamWriter(Stream stream, Encoding encoding, int bufferSize)
 {
     _stream = stream;
     Encoding = encoding;
     _encoder = encoding.GetEncoder();
     _charBufferSize = bufferSize;
     _charBuffer = new ArraySegment<char>(new char[bufferSize]);
     _byteBuffer = new ArraySegment<byte>(new byte[encoding.GetMaxByteCount(bufferSize)]);
 }
开发者ID:benaadams,项目名称:mvc-sandbox,代码行数:9,代码来源:HttpResponseStreamWriter.cs

示例6: TextReaderStream

 public TextReaderStream(TextReader textReader, Encoding encoding, int bufferSize = 4096)
 {
     _textReader = textReader;
     _encoding = encoding;
     _maxByteCountPerChar = _encoding.GetMaxByteCount(1);
     _encoder = encoding.GetEncoder();
     if (bufferSize <= 0) throw new ArgumentOutOfRangeException("bufferSize", "zero or negative");
     _charBuffer = new char[bufferSize];
 }
开发者ID:dmit25,项目名称:ntextcat,代码行数:9,代码来源:TextReaderStream.cs

示例7: TranscodingStream

        private TranscodingStream(Stream stream, Encoding outEncoding)
        {
            if (stream == null)
                throw new ArgumentNullException("stream");

            if (outEncoding == null)
                throw new ArgumentNullException("outEncoding");

            this._stream = stream;
            this._encoder = outEncoding.GetEncoder();
        }
开发者ID:riha,项目名称:CharacterTranscoder,代码行数:11,代码来源:TranscodingStream.cs

示例8: StringToPtr

 	public static IntPtr StringToPtr(string value, Encoding encoding)
     {
         var encoder = encoding.GetEncoder();
         var length = encoding.GetByteCount(value);
         // The encoded value is null terminated that's the reason for the '+1'.
         var encodedValue = new byte[length + 1];
         encoding.GetBytes(value, 0, value.Length, encodedValue, 0);
         var handle = Marshal.AllocHGlobal(new IntPtr(encodedValue.Length));
         Marshal.Copy(encodedValue, 0, handle, encodedValue.Length);
         return handle;
     }
开发者ID:Picazsoo,项目名称:tesseract,代码行数:11,代码来源:MarshalHelper.cs

示例9: SHA1TextReader

        /// <summary>
        /// 
        /// </summary>
        /// <param name="input"></param>
        /// <param name="encoding"></param>
        public SHA1TextReader(TextReader input, Encoding encoding)
            : base()
        {
            this.input = input;
            this.encoder = encoding.GetEncoder();

            this.sha1 = SHA1.Create();

            this.ibuf = new char[bufferSize];
            this.obuf = new byte[bufferSize];
            this.ibufIndex = 0;
        }
开发者ID:GamesDesignArt,项目名称:UniversalCommon,代码行数:17,代码来源:SHA1TextReader.cs

示例10: convert

        public static String convert(string sourceValue, Encoding source, Encoding target)
        {
            Encoder encoder = source.GetEncoder();
            Decoder decoder = target.GetDecoder();

            byte[] cpBytes = source.GetBytes(sourceValue);
            int bytesCount = source.GetByteCount(sourceValue);
            byte[] utfBytes = Encoding.Convert(source, target, cpBytes);
            char[] utfChars = new char[bytesCount];
            decoder.GetChars(utfBytes, 0, utfBytes.Length, utfChars, 0);

            return new String(utfChars);
        }
开发者ID:exodev,项目名称:jcr-msofficeplugin,代码行数:13,代码来源:TextUtils.cs

示例11: AsyncStreamWriter

        public AsyncStreamWriter(Stream stream, Encoding encoding, int initialBufferCapacity = DefaultIniBufferCapacity, int maxBufferCapacity = DefaultMaxBufferCapacity)
        {
            if (initialBufferCapacity < 4)
                throw new ArgumentOutOfRangeException("initialBufferCapacity");

            if (initialBufferCapacity > maxBufferCapacity)
                maxBufferCapacity = initialBufferCapacity;

            _stream = stream;
            _buffer = new byte[initialBufferCapacity];
            _maxBufferCapacity = maxBufferCapacity;
            _encoder = encoding.GetEncoder();
        }
开发者ID:ianclegg,项目名称:StompNet,代码行数:13,代码来源:AsyncStreamWriter.cs

示例12: BufferedBinaryWriter

        public unsafe BufferedBinaryWriter(Stream output, Encoding encoding)
            : base(output, encoding)
        {
            this.memoryPage = Pool.GetPage();

            this.basePtr = this.memoryPage.BasePtr;
            this.endPtr = this.memoryPage.EndPtr;

            this.ptr = this.basePtr;
            this.encoding = encoding;
            this.encoder = encoding.GetEncoder();
            this.charMaxByteCount = encoding.IsSingleByte ? 1 : encoding.GetMaxByteCount(1);
        }
开发者ID:andysoftdev,项目名称:ht4o,代码行数:13,代码来源:BufferedBinaryWriter.cs

示例13: BinaryWriter

     public BinaryWriter(Stream output, Encoding encoding)
     {
         if (output==null)
             throw new ArgumentNullException("output");
         if (encoding==null)
             throw new ArgumentNullException("encoding");
         if (!output.CanWrite)
             throw new ArgumentException(Environment.GetResourceString("Argument_StreamNotWritable"));
 
         OutStream = output;
         _buffer = new byte[16];
         _encoding = encoding;
         _encoder = _encoding.GetEncoder();
     }
开发者ID:gbarnett,项目名称:shared-source-cli-2.0,代码行数:14,代码来源:binarywriter.cs

示例14: NpgsqlBuffer

        internal NpgsqlBuffer(Stream underlying, int size, Encoding textEncoding)
        {
            if (size < MinimumBufferSize) {
                throw new ArgumentOutOfRangeException("size", size, "Buffer size must be at least " + MinimumBufferSize);
            }
            Contract.EndContractBlock();

            Underlying = underlying;
            Size = size;
            _buf = new byte[Size];
            TextEncoding = textEncoding;
            _textDecoder = TextEncoding.GetDecoder();
            _textEncoder = TextEncoding.GetEncoder();
            _tempCharBuf = new char[1024];
            _workspace = new byte[8];
        }
开发者ID:ru-sh,项目名称:npgsql,代码行数:16,代码来源:NpgsqlBuffer.cs

示例15: BinaryWriter

     public BinaryWriter(Stream output, Encoding encoding, bool leaveOpen)
     {
         if (output==null)
             throw new ArgumentNullException(nameof(output));
         if (encoding==null)
             throw new ArgumentNullException(nameof(encoding));
         if (!output.CanWrite)
             throw new ArgumentException(Environment.GetResourceString("Argument_StreamNotWritable"));
         Contract.EndContractBlock();
 
         OutStream = output;
         _buffer = new byte[16];
         _encoding = encoding;
         _encoder = _encoding.GetEncoder();
         _leaveOpen = leaveOpen;
     }
开发者ID:Dmitry-Me,项目名称:coreclr,代码行数:16,代码来源:BinaryWriter.cs


注:本文中的System.Text.Encoding.GetEncoder方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。