MCPcopy Create free account
hub / github.com/crazytuzi/UnrealCSharp / Encode

Method Encode

Source/UnrealCSharpCore/Private/Common/NameEncode.cpp:58–166  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

56}
57
58FString FNameEncode::Encode(const FString& InName, const bool bEncodeWideString)
59{
60 constexpr auto kNormal = 1;
61
62 constexpr auto kEscapeChar = 2;
63
64 constexpr auto kUnicodeString = 3;
65
66 FString Ret;
67
68 Ret.Reserve(InName.Len() + 4);
69
70 const auto LastIndex = InName.Len() - 1;
71
72 auto LastState = kNormal;
73
74 for (auto i = 0; i < InName.Len(); ++i)
75 {
76 const auto C = InName[i];
77
78 if (C == ESCAPE_HEAD_NUMBER)
79 {
80 // @TODO
81
82 return {};
83 }
84
85 const auto bEscapeSymbol = C == ESCAPE_SYMBOL_FIRST && i != LastIndex && InName[i + 1] == ESCAPE_SYMBOL_SECOND;
86
87 const auto bDigitHead = i == 0 && ::isdigit(C);
88
89 if (bDigitHead)
90 {
91 Ret.AppendChars(ESCAPE_SYMBOL, ESCAPE_SYMBOL_LEN);
92
93 Ret.AppendChars(ESCAPE_HEAD_NUMBER_SYMBOL, 2);
94
95 Ret.AppendChar(ESCAPE_END_SYMBOL);
96
97 Ret.AppendChar(C);
98
99 LastState = kEscapeChar;
100 }
101 else if (bEscapeSymbol || ShouldEscape(C))
102 {
103 Ret.AppendChars(ESCAPE_SYMBOL, ESCAPE_SYMBOL_LEN);
104
105 TCHAR Hex[2];
106
107 ByteToHex(C, Hex);
108
109 Ret.AppendChars(Hex, 2);
110
111 // skip escape symbol
112 if (bEscapeSymbol)
113 {
114 ++i;
115 }

Callers

nothing calls this directly

Calls 2

ShouldEscapeFunction · 0.85
ByteToHexFunction · 0.85

Tested by

no test coverage detected