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

fix: support chinese for enum #1913

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

fix: support chinese for enum #1913

wants to merge 3 commits into from

Conversation

wleven
Copy link

@wleven wleven commented Nov 28, 2023

support chinese string for enum

@wleven
Copy link
Author

wleven commented Jan 17, 2024

@ferdikoomen review

@@ -20,7 +20,7 @@ export const getEnum = (values?: (string | number)[]): Enum[] => {
}
return {
name: String(value)
.replace(/\W+/g, '_')
.replace(/[^a-zA-Z0-9_\u4e00-\u9fa5]+/g, '_')
Copy link

@PetrusAsikainen PetrusAsikainen Feb 13, 2024

Choose a reason for hiding this comment

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

If the name is used as an identifier, the correct characters to include would be the ones with the ID_Start or ID_Continue Unicode property. The CJK characters in the BMP with ID_Start are currently \u3400-\u4DBF\u4E00-\u9FFF\uF900-\uFAD9.

It could also make sense to already allow all characters with the correct Unicode properties, though that would probably require a dependency to pull off.

@josstn
Copy link

josstn commented Feb 14, 2024

I had a similar need to support nordic characters, so based on @PetrusAsikainen's mdn link about identifiers above, I've created another PR that I believe handles all valid identifier characters: #2038

Maybe that could be merged instead of this one?

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

Successfully merging this pull request may close these issues.

3 participants