From 66f5e4004ad3c374cfad2c8596a3a75957d18854 Mon Sep 17 00:00:00 2001 From: getnamo Date: Sun, 3 Dec 2023 11:15:33 -0800 Subject: [PATCH] fix utf8 serialization - lengths were not guaranteed to be the same between tchar and utf8. This might've been a long-standing bug! --- Source/CoreUtility/Private/CUBlueprintLibrary.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Source/CoreUtility/Private/CUBlueprintLibrary.cpp b/Source/CoreUtility/Private/CUBlueprintLibrary.cpp index 868be0b..c10fefb 100644 --- a/Source/CoreUtility/Private/CUBlueprintLibrary.cpp +++ b/Source/CoreUtility/Private/CUBlueprintLibrary.cpp @@ -47,7 +47,12 @@ FString UCUBlueprintLibrary::Conv_BytesToString(const TArray& InArray) TArray UCUBlueprintLibrary::Conv_StringToBytes(FString InString) { TArray ResultBytes; - ResultBytes.Append((uint8*)TCHAR_TO_UTF8(*InString), InString.Len()); + + FTCHARToUTF8 UTF8String(*InString); + + int32 UTF8Len = UTF8String.Length(); + + ResultBytes.Append((uint8*)UTF8String.Get(), UTF8Len); return ResultBytes; }