Skip to content

Commit

Permalink
fix utf8 serialization
Browse files Browse the repository at this point in the history
- lengths were not guaranteed to be the same between tchar and utf8. This might've been a long-standing bug!
  • Loading branch information
getnamo committed Dec 3, 2023
1 parent 6e5786a commit 66f5e40
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion Source/CoreUtility/Private/CUBlueprintLibrary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,12 @@ FString UCUBlueprintLibrary::Conv_BytesToString(const TArray<uint8>& InArray)
TArray<uint8> UCUBlueprintLibrary::Conv_StringToBytes(FString InString)
{
TArray<uint8> 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;
}

Expand Down

0 comments on commit 66f5e40

Please sign in to comment.