using System.Runtime.InteropServices;
using Mono.Globalization.Unicode;
+using System.Diagnostics.Contracts;
namespace System
{
memcpy4 ((byte*)dest, (byte*)src, count * 2);
}
+ internal static unsafe void wstrcpy (char *dmem, char *smem, int charCount)
+ {
+ CharCopy (dmem, smem, charCount);
+ }
+
internal static unsafe void CharCopyReverse (char *dest, char *src, int count)
{
dest += count;
[MethodImplAttribute (MethodImplOptions.InternalCall)]
private extern static int GetLOSLimit ();
+
+#region "from referencesource" // and actually we replaced some parts.
+
+ // Helper for encodings so they can talk to our buffer directly
+ // stringLength must be the exact size we'll expect
+ [System.Security.SecurityCritical] // auto-generated
+ unsafe static internal String CreateStringFromEncoding(
+ byte* bytes, int byteLength, Encoding encoding)
+ {
+ Contract.Requires(bytes != null);
+ Contract.Requires(byteLength >= 0);
+
+ // Get our string length
+ int stringLength = encoding.GetCharCount(bytes, byteLength, null);
+ Contract.Assert(stringLength >= 0, "stringLength >= 0");
+
+ // They gave us an empty string if they needed one
+ // 0 bytelength might be possible if there's something in an encoder
+ if (stringLength == 0)
+ return String.Empty;
+
+ String s = FastAllocateString(stringLength);
+ fixed(char* pTempChars = &s.start_char)
+ {
+ int doubleCheck = encoding.GetChars(bytes, byteLength, pTempChars, stringLength, null);
+ Contract.Assert(stringLength == doubleCheck,
+ "Expected encoding.GetChars to return same length as encoding.GetCharCount");
+ }
+
+ return s;
+ }
+
+ // our own implementation for CLR icall.
+ unsafe internal static int nativeCompareOrdinalIgnoreCaseWC (string name, sbyte *strBBytes)
+ {
+ for (int i = 0; i < name.Length; i++) {
+ sbyte b = *(strBBytes + i);
+ if (b < 0)
+ throw new ArgumentException ();
+ int ret = char.ToUpper ((char) b) - char.ToUpper (name [i]);
+ if (ret != 0)
+ return ret;
+ }
+ return 0;
+ }
+#endregion
}
}