/// <summary> /// Ensures that m_buffer is at least length bytes long, growing it if necessary /// </summary> /// <param name="length"></param> //void CheckBuffer(int length) { // if (m_buffer.Length <= length) { // byte[] new_buffer = new byte[length]; // Array.Copy(m_buffer, 0, new_buffer, 0, m_buffer.Length); // m_buffer = new_buffer; // } //} /// <summary> /// liest eine Zeichenkette bis zum 0-Byte oder bis die max. Länge erreicht ist /// </summary> /// <param name="br"></param> /// <param name="maxlen"></param> /// <param name="encoder"></param> /// <returns></returns> public string ReadString(int maxlen = 0, Encoding encoder = null) { List <byte> dat = new List <byte>(); byte b; int len = maxlen > 0 ? maxlen : int.MaxValue; do { b = ReadByte(); if (b != 0) { dat.Add(b); } len--; } while (b != 0 && len > 0); return(encoder == null?StandardEncoding.GetString(dat.ToArray()) : encoder.GetString(dat.ToArray())); }
static Encoding() { Default = new StandardEncoding(); Default.CodePage = (int)GetACP(); ASCII = new StandardEncoding(); ASCII.CodePage = 20127; UTF7 = new StandardEncoding(); UTF7.CodePage = 65000; UTF8 = new StandardEncoding(); UTF8.CodePage = 65001; Unicode = new StandardEncoding(); Unicode.CodePage = 1200; BigEndianUnicode = new StandardEncoding(); BigEndianUnicode.CodePage = 1201; UTF32 = new StandardEncoding(); UTF32.CodePage = 12000; }