MCPcopy Create free account
hub / github.com/OpenStarbound/OpenStarbound / parseUnicodeEscapeSequence

Method parseUnicodeEscapeSequence

source/core/StarShellParser.cpp:172–202  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

170}
171
172auto ShellParser::parseUnicodeEscapeSequence(Maybe<Char> previousCodepoint) -> Char {
173 String codepoint;
174
175 auto letter = current();
176
177 while (!isSpace(*letter) && codepoint.size() < 4) {
178 auto letter = next();
179 if (!letter) {
180 break;
181 }
182
183 if (!isxdigit(*letter)) {
184 return STAR_UTF32_REPLACEMENT_CHAR;
185 }
186
187 codepoint.append(*letter);
188 }
189
190 if (!codepoint.size()) {
191 return 'u';
192 }
193
194 if (codepoint.size() != 4) // exactly 4 digits are required by \u
195 return STAR_UTF32_REPLACEMENT_CHAR;
196
197 try {
198 return hexStringToUtf32(codepoint.utf8(), previousCodepoint);
199 } catch (UnicodeException const&) {
200 return STAR_UTF32_REPLACEMENT_CHAR;
201 }
202}
203
204bool ShellParser::notDone() const {
205 return m_current != m_end;

Callers

nothing calls this directly

Calls 3

hexStringToUtf32Function · 0.85
sizeMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected