RealDocs

FName::TryAppendAnsiString

function Core Since 5.0
#include "UObject/NameTypes.h"
Access: public Specifiers: const

Description

Converts this FName to its string representation and appends it to an ANSI string builder. Returns false if the underlying name entry was stored as wide characters — in that case nothing is written.

Caveats & Gotchas

  • Returns false without modifying the builder when the name contains non-ANSI (wide) characters. Callers must handle this case explicitly and fall back to AppendString or ToString.
  • The numeric suffix of a numbered name (e.g. '_3' in 'Actor_3') is included in the appended output — the function writes the full ToString()-equivalent text, not just the base string.

Signature

CORE_API bool TryAppendAnsiString(FAnsiStringBuilderBase& Out) const;

Parameters

Name Type Description Default
Out FAnsiStringBuilderBase& The ANSI string builder to append the name string into.

Return Type

bool

Example

Append with wide-character fallback C++
TAnsiStringBuilder<128> Builder;
if (!MyName.TryAppendAnsiString(Builder))
{
    // Name contains wide characters; fall back to FString
    FString Wide = MyName.ToString();
    UE_LOG(LogTemp, Warning, TEXT("Wide name: %s"), *Wide);
}

Version History

Introduced in: 5.0

Version Status Notes
5.6 stable

Feedback

Was this helpful?

Suggest an edit

Select a field above to begin editing.