FString TestStr = TEXT(“中文”);
TCHAR_TO_ANSI(*TestStr); // the convert result is “??”
TCHAR_TO_ANSI can’t convert chinese characters to ANSI. How to fix this?
P.S. This same code works in UE3.
FString TestStr = TEXT(“中文”);
TCHAR_TO_ANSI(*TestStr); // the convert result is “??”
TCHAR_TO_ANSI can’t convert chinese characters to ANSI. How to fix this?
P.S. This same code works in UE3.
The internet tells me that ANSI-Char is 8-bit, which can represent 256 characters. Chinese cannot fit into a ANSI-Char. If that worked in UE3 than ANSI-Char in UE3 was not actually ANSI-Char. It is not possible for ANSI to hold chinese characters. This is what it can hold.
ANSI use 2 bytes to represent chinese characters. For example
char ANSI(GBK)
中 0xD6D0
char ANSI(GBK)
文 0xCEC4
in UE3, TCHAR_TO_ANSI use WideCharToMultiByte to covert between TCHAR and ANSI on Windows