MCPcopy Create free account
hub / github.com/Redot-Engine/redot-engine / validate_unicode_identifier

Method validate_unicode_identifier

core/string/ustring.cpp:4575–4596  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4573}
4574
4575String String::validate_unicode_identifier() const {
4576 if (is_empty()) {
4577 return "_"; // Empty string is not a valid identifier.
4578 }
4579
4580 String result;
4581 if (is_unicode_identifier_start(operator[](0))) {
4582 result = *this;
4583 } else {
4584 result = "_" + *this;
4585 }
4586
4587 int len = result.length();
4588 char32_t *buffer = result.ptrw();
4589 for (int i = 0; i < len; i++) {
4590 if (!is_unicode_identifier_continue(buffer[i])) {
4591 buffer[i] = '_';
4592 }
4593 }
4594
4595 return result;
4596}
4597
4598bool String::is_valid_ascii_identifier() const {
4599 int len = length();

Callers 4

make_templateMethod · 0.80
drop_data_fwMethod · 0.80
test_string.hFile · 0.80

Calls 4

lengthMethod · 0.45
ptrwMethod · 0.45

Tested by

no test coverage detected