| 4573 | } |
| 4574 | |
| 4575 | String 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 | |
| 4598 | bool String::is_valid_ascii_identifier() const { |
| 4599 | int len = length(); |
no test coverage detected