private unsafe void CreateFirstSubstData(string s, IIS7WorkerRequest iis7WorkerRequest, System.Text.Encoder encoder) { IntPtr ptr; int num = 0; int length = s.Length; if (length > 0) { fixed (char* str = ((char*) s)) { char* chars = str; int size = encoder.GetByteCount(chars, length, true); ptr = iis7WorkerRequest.AllocateRequestMemory(size); if (ptr != IntPtr.Zero) { num = encoder.GetBytes(chars, length, (byte*) ptr, size, true); } } } else { ptr = iis7WorkerRequest.AllocateRequestMemory(1); } if (ptr == IntPtr.Zero) { throw new OutOfMemoryException(); } this._firstSubstData = ptr; this._firstSubstDataSize = num; }
public static int CountAsBytes(string s, System.Text.Encoding _enc) { return _enc.GetByteCount(s); }
private static sbyte[] GetSBytesForEncoding(System.Text.Encoding encoding, string s) { sbyte[] sbytes = new sbyte[encoding.GetByteCount(s)]; encoding.GetBytes(s, 0, s.Length, (byte[])(object)sbytes, 0); return sbytes; }
private static byte[] GetbytesForEncoding(System.Text.Encoding encoding, string s) { byte[] bytes = new byte[encoding.GetByteCount(s)]; encoding.GetBytes(s, 0, s.Length, (byte[])(object)bytes, 0); return bytes; }
private static unsafe int GetByteCount(System.Text.Encoding encoding, string value, int offset, int size) { int byteCount; fixed (char* chPtr = value) { byteCount = encoding.GetByteCount(chPtr + offset, size); } return byteCount; }