Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add String.is_valid_unicode_identifier() #95984

Merged
merged 1 commit into from
Aug 27, 2024

Conversation

timothyqiu
Copy link
Member

Implements godotengine/godot-proposals#9851

Rationale:

  • The old is_valid_identifier() is checking for traditional ASCII identifiers. Its name can be confusing because GDScript implements Unicode identifiers.
  • There is currently no way to check according to GDScript's rule of Unicode identifiers. TextServer.is_valid_identifier() is close, but advanced text server adds extra conversions and rules. Text server extensions could potentially also change the rules.

This PR:

  • Adds is_valid_unicode_identifier(): Basic unicode identifier checking, the same as how GDScript parses identifiers
  • Adds is_valid_ascii_identifier() : Same as the old is_valid_identifier()
  • Deprecates is_valid_identifier()
  • Renames internal method validate_identifier() to validate_ascii_identifier()

Copy link
Member

@Calinou Calinou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change makes sense to me. I've been wondering how to check for a valid Unicode identifier recently from a script, in fact 🙂

Copy link
Contributor

@Mickeon Mickeon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The first line of the new method's description could be a bit more detailed to entail what a "valid Unicode identifier" means, at least roughly.

The examples could also be more distinct than is_valid_identifier's, such as using accented letters and similar.

@akien-mga akien-mga requested a review from bruvzg August 26, 2024 20:38
- Adds `is_valid_unicode_identifier()`
- Adds `is_valid_ascii_identifier()`
- Deprecates `is_valid_identifier()`
- Renames `validate_identifier()` to `validate_ascii_identifier()`
@akien-mga akien-mga merged commit 9dfc415 into godotengine:master Aug 27, 2024
18 checks passed
@akien-mga
Copy link
Member

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants