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

Correctly handle Unicode characters #60

Closed
sunknudsen opened this issue Mar 3, 2020 · 3 comments · Fixed by #62
Closed

Correctly handle Unicode characters #60

sunknudsen opened this issue Mar 3, 2020 · 3 comments · Fixed by #62

Comments

@sunknudsen
Copy link

The regular expressions in this package don’t support unicode characters such as àçéèù so camelCase("Licorne époustouflante") outputs licorne époustouflante.

Perhaps we could add a transliterate option that leverages transliterate so camelCase("Licorne époustouflante", { transliterate: true }) outputs licorneEpoustouflante.

Another slightly more complicated alternative would be to have camelCase("Licorne époustouflante", { transliterate: true }) output licorneÉpoustouflante.

What do you think? I could put a PR together.

@sunknudsen
Copy link
Author

sunknudsen commented Mar 3, 2020

Perhaps adding a camelcase option to @sindresorhus/slugify might a better alternative.

Looking for a way to convert any JavaScript property name (which can include all unicode characters) to camel case.

@sindresorhus
Copy link
Owner

A better way would be for the regexes used here to use Unicode property escapes, like done in https://github.com/sindresorhus/decamelize/blob/b445ed47a5548e2ba8fe41889807d17879faa7c5/index.js#L9-L10

@sindresorhus sindresorhus changed the title Adding a transliterate option to convert and camel case unicode characters Correctly handle Unicode characters Mar 4, 2020
@sverweij
Copy link
Contributor

@sunknudsen / @sindresorhus I've put up a fix for this (see☝️, PR #62) which employs Unicode property escapes as suggested.

You can test whether it works for your use case by running npm install sverweij/camelcase. This will install it directly from the forked repo on github - the code will live there only until it's merged into this repo. Or when a better fix comes along, of course :-)

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

Successfully merging a pull request may close this issue.

3 participants