UTF8 Marshaling APIs (#3736)
[mono.git] / mcs / class / referencesource / mscorlib / system / string.cs
index 3f96ac1c00e42170e0153dea36793ab74d142992..e8fe32e54d119a9dffc79131c9a1106c06ab56e2 100644 (file)
@@ -1392,6 +1392,16 @@ namespace System {
 
             return s;
         }
+
+        unsafe internal int GetBytesFromEncoding(byte* pbNativeBuffer, int cbNativeBuffer,Encoding encoding)
+        {
+            // encoding == Encoding.UTF8
+            fixed (char* pwzChar = &this.m_firstChar)
+            {
+                return encoding.GetBytes(pwzChar, m_stringLength, pbNativeBuffer, cbNativeBuffer);
+            }
+        }
+
 #if !MONO
         [System.Security.SecuritySafeCritical]  // auto-generated
         unsafe internal int ConvertToAnsi(byte *pbNativeBuffer, int cbNativeBuffer, bool fBestFit, bool fThrowOnUnmappableChar)