Replace delimiters with unicode shapes
This commit is contained in:
@@ -51,7 +51,16 @@ extern int32 TrySavePackageSEH(
|
||||
#endif
|
||||
|
||||
// ============================================================
|
||||
// Name Formatting
|
||||
// Name sanitization
|
||||
//
|
||||
// Our parsers use Unicode geometric shape delimiters that
|
||||
// are unlikely to appear in names: ◂▸ for type brackets, ◆
|
||||
// for map key◆value, ◦ for type◦name in prototypes, │ for
|
||||
// list/path separation. If any of these characters appear
|
||||
// in a name, we replace them with safe ASCII equivalents.
|
||||
// One consequence of name sanitization is that we can't use
|
||||
// Unreal's name-lookup routines — the LLM only sees
|
||||
// sanitized names. So we do our own name lookups.
|
||||
// ============================================================
|
||||
|
||||
void WingUtils::SanitizeNameInPlace(FString &Name)
|
||||
@@ -61,7 +70,11 @@ void WingUtils::SanitizeNameInPlace(FString &Name)
|
||||
{
|
||||
TCHAR c = Name[Src];
|
||||
if (c < 0x20 || c == 0x7F) continue;
|
||||
if ((c == ' ') || (c == ',') || (c == ':')) c = '_';
|
||||
if (c == L'◂') c='<';
|
||||
if (c == L'▸') c='>';
|
||||
if (c == L'◆') c='*';
|
||||
if (c == L'◦') c='.';
|
||||
if (c == L'│') c = '|';
|
||||
Name[Dst++] = c;
|
||||
}
|
||||
if (Dst == 0) Name[Dst++] = '_';
|
||||
@@ -82,6 +95,10 @@ FString WingUtils::SanitizeName(FName Name)
|
||||
return Result;
|
||||
}
|
||||
|
||||
// ============================================================
|
||||
// Name Lookup
|
||||
// ============================================================
|
||||
|
||||
FString WingUtils::FormatName(const UWorld *World)
|
||||
{
|
||||
return World->GetPathName();
|
||||
|
||||
Reference in New Issue
Block a user