Beispiel #1
0
 public void Append(char[] buffer, int start, int length)
 {
     if (IsUnicode)
     {
         UnicodeBuilder.Append(buffer, start, length);
     }
     else
     {
         BinaryBuilder.AddRange(encoding.GetBytes(buffer, start, length));
     }
 }
Beispiel #2
0
 public void Append(string str)
 {
     if (IsUnicode)
     {
         UnicodeBuilder.Append(str);
     }
     else
     {
         BinaryBuilder.AddRange(encoding.GetBytes(str));
     }
 }
Beispiel #3
0
        public void Append(byte b)
        {
            // force binary string

            if (IsUnicode && b <= 0x7f)
            {
                UnicodeBuilder.Append((char)b);
            }
            else
            {
                // we have to store the string as a single-byte array
                BinaryBuilder.Add(b);
            }
        }
Beispiel #4
0
        public void Append(int c)
        {
            Debug.Assert(c >= 0);

            //if (c <= 0xff)
            if (IsBinary)
            {
                BinaryBuilder.Add((byte)c);
            }
            else
            {
                UnicodeBuilder.Append((char)c);
            }
        }
Beispiel #5
0
        public void Append(byte b)
        {
            // force binary string

            if (IsUnicode)
            {
                encodeBytes[0] = b;
                UnicodeBuilder.Append(encodeChars, 0, encoding.GetChars(encodeBytes, 0, 1, encodeChars, 0));
            }
            else
            {
                BinaryBuilder.Add(b);
            }
        }
Beispiel #6
0
 public void Append(char c)
 {
     if (IsUnicode)
     {
         UnicodeBuilder.Append(c);
     }
     else
     {
         encodeChars[0] = c;
         int count = encoding.GetBytes(encodeChars, 0, 1, encodeBytes, 0);
         for (int i = 0; i < count; ++i)
         {
             BinaryBuilder.Add(encodeBytes[i]);
         }
     }
 }
Beispiel #7
0
 public PhpStringBuilder(Encoding /*!*/ encoding, string /*!*/ value)
     : this(encoding, false, value.Length)
 {
     UnicodeBuilder.Append(value);
 }