本文整理汇总了C#中System.Text.Encoder类的典型用法代码示例。如果您正苦于以下问题:C# Encoder类的具体用法?C# Encoder怎么用?C# Encoder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Encoder类属于System.Text命名空间,在下文中一共展示了Encoder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetRealObject
public object GetRealObject (StreamingContext context)
{
if (this.realObject == null)
this.realObject = this.encoding.GetEncoder ();
return this.realObject;
}
示例2: 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();
}
示例3: XmlEncodedRawTextWriter
public XmlEncodedRawTextWriter(Stream stream, XmlWriterSettings settings) : this(settings)
{
this.stream = stream;
this.encoding = settings.Encoding;
this.bufChars = new char[0x1820];
this.bufBytes = new byte[this.bufChars.Length];
this.bufBytesUsed = 0;
this.trackTextContent = true;
this.inTextContent = false;
this.lastMarkPos = 0;
this.textContentMarks = new int[0x40];
this.textContentMarks[0] = 1;
this.charEntityFallback = new CharEntityEncoderFallback();
this.encoding = (Encoding) settings.Encoding.Clone();
this.encoding.EncoderFallback = this.charEntityFallback;
this.encoder = this.encoding.GetEncoder();
if (!stream.CanSeek || (stream.Position == 0L))
{
byte[] preamble = this.encoding.GetPreamble();
if (preamble.Length != 0)
{
this.stream.Write(preamble, 0, preamble.Length);
}
}
if (settings.AutoXmlDeclaration)
{
this.WriteXmlDeclaration(this.standalone);
this.autoXmlDeclaration = true;
}
}
示例4: 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();
}
示例5: MemoryPoolTextWriter
public MemoryPoolTextWriter(IMemoryPool memory)
{
_memory = memory;
_textArray = _memory.AllocChar(_textLength);
_dataArray = _memory.Empty;
_encoder = Encoding.UTF8.GetEncoder();
}
示例6: ByteBuffer
/// <summary>
/// 构造函数
/// </summary>
public ByteBuffer()
{
this.BaseStream = new MemoryStream();
this._buffer = new byte[0x10];
this._encoding = Encoding.Default;//(false, true);
this._encoder = this._encoding.GetEncoder();
}
示例7: StaticUtils
static StaticUtils()
{
asciiDecoder = Encoding.ASCII.GetDecoder();
utf8Encoder = Encoding.UTF8.GetEncoder();
utf8Decoder = Encoding.UTF8.GetDecoder();
}
示例8: 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];
}
示例9: 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();
}
示例10: MemoryPoolTextWriter
public MemoryPoolTextWriter(IMemoryPool memory)
: base(CultureInfo.InvariantCulture)
{
_memory = memory;
_textArray = _memory.AllocChar(_textLength);
_dataArray = MemoryPool.EmptyArray;
_encoder = Encoding.UTF8.GetEncoder();
}
示例11: Hash
public static int Hash(string data, Encoder enc)
{
var arr = data.ToCharArray();
int count = enc.GetByteCount(arr, 0, arr.Length, false);
var bytes = new byte[count];
enc.GetBytes(arr, 0, arr.Length, bytes, 0, false);
return Hash(bytes);
}
示例12: BinaryWriter
protected BinaryWriter()
{
this._tmpOneCharBuffer = new char[1];
this.OutStream = Stream.Null;
this._buffer = new byte[0x10];
this._encoding = new UTF8Encoding(false, true);
this._encoder = this._encoding.GetEncoder();
}
示例13: 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];
}
示例14: 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)]);
}
示例15: LineWriter
public LineWriter(Stream stream, int bufferSize) {
if (bufferSize < 1024)
bufferSize = 1024;
this.stream = stream;
writeBuffer = new byte[bufferSize];
writeBufferOffset = 0;
encoder = Encoding.UTF8.GetEncoder();
}