Add String.is_valid_unicode_identifier()
- Adds `is_valid_unicode_identifier()` - Adds `is_valid_ascii_identifier()` - Deprecates `is_valid_identifier()` - Renames `validate_identifier()` to `validate_ascii_identifier()`
This commit is contained in:
@@ -112,7 +112,7 @@ Error RDShaderFile::parse_versions_from_text(const String &p_text, const String
|
||||
}
|
||||
Vector<String> slices = l.get_slice(";", 0).split("=");
|
||||
String version = slices[0].strip_edges();
|
||||
if (!version.is_valid_identifier()) {
|
||||
if (!version.is_valid_ascii_identifier()) {
|
||||
base_error = "Version names must be valid identifiers, found '" + version + "' instead.";
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -173,7 +173,7 @@ String ShaderPreprocessor::Tokenizer::get_identifier(bool *r_is_cursor, bool p_s
|
||||
}
|
||||
|
||||
String id = vector_to_string(text);
|
||||
if (!id.is_valid_identifier()) {
|
||||
if (!id.is_valid_ascii_identifier()) {
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
@@ -2165,23 +2165,7 @@ TypedArray<Dictionary> TextServer::_shaped_text_get_ellipsis_glyphs_wrapper(cons
|
||||
}
|
||||
|
||||
bool TextServer::is_valid_identifier(const String &p_string) const {
|
||||
const char32_t *str = p_string.ptr();
|
||||
int len = p_string.length();
|
||||
|
||||
if (len == 0) {
|
||||
return false; // Empty string.
|
||||
}
|
||||
|
||||
if (!is_unicode_identifier_start(str[0])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (int i = 1; i < len; i++) {
|
||||
if (!is_unicode_identifier_continue(str[i])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
return p_string.is_valid_unicode_identifier();
|
||||
}
|
||||
|
||||
bool TextServer::is_valid_letter(uint64_t p_unicode) const {
|
||||
|
||||
Reference in New Issue
Block a user