Convert FString to TCHAR

How do I convert a FString to a TCHAR?

Example: TCHAR * wavLink = MyTextVariable

Not working: TCHAR * wavLink = ANSI_TO_TCHAR(MyTextVariable);

I get cannot convert from β€˜const TCHAR *’ to 'TCHAR *

FString UWav::Wav(FString MyTextVariable)
	TCHAR* wavLink = *MyTextVariable;
	return "Done";

Hi Taurian,

To convert an FString to a TCHAR array, all you need to do is dereference the FString variable. Using your example, this should work: TCHAR* wavLink = *MyTextVariable;


Sorry, I forgot to include const in my code snippet. It should have read: const TCHAR* wavLink = *MyTextVariable;

The FString dereferences as a const TCHAR array because it is unsafe to make modifications to the array directly.


Niiice. Thanks.

Thx , it works

* Get pointer to the string
* @Return Pointer to Array of TCHAR if Num, otherwise the empty string
operator*() const
return Data.Num() ? Data.GetData() : TEXT(β€œβ€);

From UE4.19, it seems *FString can only work form num string.

1 Like