Fix script editor wrongly replaces and quotes non-ASCII letters
This commit is contained in:
parent
e4e024ab88
commit
a751c05b15
5 changed files with 46 additions and 8 deletions
|
|
@ -4626,7 +4626,7 @@ bool String::is_absolute_path() const {
|
|||
|
||||
String String::validate_ascii_identifier() const {
|
||||
if (is_empty()) {
|
||||
return "_"; // Empty string is not a valid identifier;
|
||||
return "_"; // Empty string is not a valid identifier.
|
||||
}
|
||||
|
||||
String result;
|
||||
|
|
@ -4647,6 +4647,29 @@ String String::validate_ascii_identifier() const {
|
|||
return result;
|
||||
}
|
||||
|
||||
String String::validate_unicode_identifier() const {
|
||||
if (is_empty()) {
|
||||
return "_"; // Empty string is not a valid identifier.
|
||||
}
|
||||
|
||||
String result;
|
||||
if (is_unicode_identifier_start(operator[](0))) {
|
||||
result = *this;
|
||||
} else {
|
||||
result = "_" + *this;
|
||||
}
|
||||
|
||||
int len = result.length();
|
||||
char32_t *buffer = result.ptrw();
|
||||
for (int i = 0; i < len; i++) {
|
||||
if (!is_unicode_identifier_continue(buffer[i])) {
|
||||
buffer[i] = '_';
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
bool String::is_valid_ascii_identifier() const {
|
||||
int len = length();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue