Hello…
I have Hex stored in FString “0x0041”.
How i can convert that hex (utf16 code) to character or string ??
Hello…
I have Hex stored in FString “0x0041”.
How i can convert that hex (utf16 code) to character or string ??
FString HexCode = “0041”;
char* _HexCode = TCHAR_TO_ANSI(*HexCode);
wchar_t wc = strtol(_HexCode, NULL, 16);
FString UtfChar = "";
UtfChar.AppendChar(wc);
If you have better solution let me know.
I don’t know if it is better or not but
bool UExtendedVarsBPLibrary::Hex_To_String(FString& Out_Decoded, FString In_Hex)
{
if (In_Hex.IsEmpty())
{
return false;
}
for (size_t Index_Chars = 0; Index_Chars < In_Hex.Len(); Index_Chars += 2)
{
//taking two characters from hex string
FString Part = UKismetStringLibrary::GetSubstring(In_Hex, Index_Chars, 2);
//changing it into base 16
char Character = std::stoul(TCHAR_TO_UTF8(*Part), nullptr, 16);
//putting it into the ASCII string
Out_Decoded += Character;
}
return true;
}