如何在虚幻引擎4中将char*转换为TCHAR?

5
例如,
const char* bytes = "somemultibytecharacter一些宽字符";
size_t n = strlen(bytes);

如何在虚幻引擎C++代码中将bytes转换为FStringTCHAR*
我知道可以使用std::mbstowcsMultiByteToWideChar进行转换,但我正在尝试寻找UE4的替代方法。

使用TEXT宏,TCHAR* bytes = TEXT("somemultibytecharacter一些宽字符"); - George
@George,如果bytes是原始文本,则您是正确的,但在我的情况下,bytes实际上是一个外部变量,我无法控制它。http://xyproblem.info/ - zwcloud
1个回答

3

只需使用FString(int32 InCount, const CharType* InSrc)

用法:

const char* bytes = "somemultibytecharacter一些宽字符";
size_t n = strlen(bytes);
const FString& Str = FString(n, bytes);
const TCHAR* Text = *Str;

注意,在我的Unreal Engine 4副本中,TCHAR指的是wchar_t类型:
typedef wchar_t  WIDECHAR;
typedef WIDECHAR TCHAR

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接