How to use TCHAR in USTRUCT?

I want to use char type to store a single character, but LiveCoding tells me “unrecognized type ‘TCHAR’ - type must be a UCLASS, ustruct, uenum, or global delegate.”.

What should I do? What class does USTRUCT support?

USTRUCT(BlueprintType)
struct FStru_CharacterTable : public FTableRowBase
{
	GENERATED_USTRUCT_BODY()
public:
	UPROPERTY(EditAnywhere, Category = "Unicode Convert")
	FString Unicode;
	UPROPERTY(EditAnywhere, Category = "Unicode Convert")
	TCHAR Character;
};

What do you want to store in the value?
An FString is fine if you want to store a single character.
Or use an int.

1 Like

I think a character should be stored in TCHAR, such as Korean or Japanese characters.
Is it a waste if I use FString?

Maybe it is, but you don’t need to care about it because it’s too small overhead to take. I think.
Just use FString

2 Likes

In general, a single code point (which is what TCHAR is) isn’t enough to store a single symbol (which is the minimum useful increment in a language.)
There are languages that need combining characters to create a specific symbol, so a single TCHAR is not enough.

If you’re writing a large text processing program, and need to store individual code points, then, perhaps, a FString for each would be enough waste that you could measure the overhead. However, if you’re storing some symbol for a shortcut, key binding, or similar, not only is an FString (or perhaps FText, if you want localization) necessary to be able to represent all possible symbols, the overhead is also not really measurable in practice.

If you have less than 10,000 instances of this object, don’t worry about it at al. If you have more than 10,000 instances of this object, then start profiling whether optimization is needed.

1 Like

thank you