public static void TestUTF8StructMarshalling(string[] utf8Strings) { Utf8Struct utf8Struct = new Utf8Struct(); for (int i = 0; i < utf8Strings.Length; i++) { utf8Struct.FirstName = utf8Strings[i]; utf8Struct.index = i; TestStructWithUtf8Field(utf8Struct); } }
public static void TestUTF8StructMarshalling(string[] utf8Strings) { Utf8Struct utf8Struct = new Utf8Struct(); for (int i = 0; i < utf8Strings.Length; i++) { utf8Struct.FirstName = utf8Strings[i]; utf8Struct.index = i; TestStructWithUtf8Field(utf8Struct); } if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { CompareWithUTF8Encoding(); } }
public static void TestUTF8StructMarshalling(string[] utf8Strings) { Utf8Struct utf8Struct = new Utf8Struct(); for (int i = 0; i < utf8Strings.Length; i++) { utf8Struct.FirstName = utf8Strings[i]; utf8Struct.index = i; TestStructWithUtf8Field(utf8Struct); } if (!OperatingSystem.IsWindows()) { CompareWithUTF8Encoding(); } string testString = "StructTestString\uD83D\uDE00"; SetStringInStruct(ref utf8Struct, testString); if (utf8Struct.FirstName != testString) { throw new Exception("Incorrect UTF8 string marshalled back from native to managed."); } }
public static extern void TestStructWithUtf8Field(Utf8Struct utfStruct);
public static extern void SetStringInStruct(ref Utf8Struct utfStruct, [MarshalAs(UnmanagedType.LPUTF8Str)] string str);
public static bool TestUTF8StructMarshalling(string[] utf8Strings) { Utf8Struct utf8Struct = new Utf8Struct(); for (int i = 0; i < utf8Strings.Length; i++) { utf8Struct.FirstName = utf8Strings[i]; utf8Struct.index = i; TestStructWithUtf8Field(utf8Struct); } return true; }
public static extern void TestStructWithUtf8Field(Utf8Struct utfStruct);