public new string ToString()
{
string result;
JsErrorCode errorCode;
if (Utils.IsWindows())
{
IntPtr ptr;
UIntPtr stringLength;
errorCode = NativeMethods.JsStringToPointer(this, out ptr, out stringLength);
JsErrorHelpers.ThrowIfError(errorCode);
result = Marshal.PtrToStringUni(ptr, (int)stringLength);
}
else
{
byte[] buffer = null;
UIntPtr bufferSize = UIntPtr.Zero;
UIntPtr written;
errorCode = NativeMethods.JsCopyStringUtf8(this, buffer, bufferSize, out written);
JsErrorHelpers.ThrowIfError(errorCode);
buffer = new byte[(int)written];
bufferSize = new UIntPtr((uint)written);
errorCode = NativeMethods.JsCopyStringUtf8(this, buffer, bufferSize, out written);
JsErrorHelpers.ThrowIfError(errorCode);
result = Encoding.GetEncoding(0).GetString(buffer);
}
return result;
}