From eaf468e9e8d3ef17f397ef6bc5e73807a2bf3594 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 22 Sep 2022 18:54:49 +0100 Subject: [PATCH] C# CreateWStringFromUTF32 optimisation Avoid UTF-32 to UTF-8 conversion then get string from UTF-8 Issue #2369 --- Lib/csharp/wchar.i | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Lib/csharp/wchar.i b/Lib/csharp/wchar.i index 2ada4df75..39b99ee22 100644 --- a/Lib/csharp/wchar.i +++ b/Lib/csharp/wchar.i @@ -49,8 +49,7 @@ static void * SWIG_csharp_wstring_callback(const wchar_t *s) { byte[] buffer = new byte[length * 4]; global::System.Runtime.InteropServices.Marshal.Copy(cString, buffer, 0, buffer.Length); - byte[] utf8buffer = global::System.Text.Encoding.Convert(global::System.Text.Encoding.UTF32, global::System.Text.Encoding.UTF8, buffer); - return global::System.Text.Encoding.Default.GetString(utf8buffer); + return global::System.Text.Encoding.UTF32.GetString(buffer); } static SWIGWStringHelper() {