MCPcopy Create free account
hub / github.com/BernardoGiordano/Checkpoint / removeForbiddenCharacters

Method removeForbiddenCharacters

3ds/source/util.cpp:232–252  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

230}
231
232std::u16string StringUtils::removeForbiddenCharacters(std::u16string src)
233{
234 static const std::u16string illegalChars = StringUtils::UTF8toUTF16(".,!\\/:?*\"<>|");
235 for (size_t i = 0; i < src.length(); i++) {
236 if (illegalChars.find(src[i]) != std::string::npos) {
237 src[i] = ' ';
238 }
239 }
240
241 // Trim trailing spaces. find_last_not_of handles the empty / all-spaces cases
242 // (npos) without the size()-1 underflow of a reverse index loop.
243 size_t end = src.find_last_not_of(u' ');
244 if (end == std::u16string::npos) {
245 src.clear();
246 }
247 else {
248 src.erase(end + 1);
249 }
250
251 return src;
252}
253
254// One decoder and one glyph-width cache for every text-measuring path.
255namespace {

Callers

nothing calls this directly

Calls 3

findMethod · 0.80
clearMethod · 0.45
eraseMethod · 0.45

Tested by

no test coverage detected