public void Append(char[] buffer, int start, int length) { if (IsUnicode) { UnicodeBuilder.Append(buffer, start, length); } else { BinaryBuilder.AddRange(encoding.GetBytes(buffer, start, length)); } }
public void Append(string str) { if (IsUnicode) { UnicodeBuilder.Append(str); } else { BinaryBuilder.AddRange(encoding.GetBytes(str)); } }
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); } }
public void Append(int c) { Debug.Assert(c >= 0); //if (c <= 0xff) if (IsBinary) { BinaryBuilder.Add((byte)c); } else { UnicodeBuilder.Append((char)c); } }
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); } }
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]); } } }
public PhpStringBuilder(Encoding /*!*/ encoding, string /*!*/ value) : this(encoding, false, value.Length) { UnicodeBuilder.Append(value); }