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 capitalization for non-English strings #42

Merged
merged 1 commit into from
Aug 28, 2020

Conversation

divan
Copy link
Contributor

@divan divan commented Apr 11, 2020

The current Capitalize implementation is broken for non-English strings. I didn't dive deep into analysis of the problem, but the problem seems to appear in the concatenation of i.Original[1:] to the capitalized letter. It works only under assumtion that rune of the first character takes exactly 1 byte, which is not true for non-English UTF-8 encoded strings.

My version assumes that capitalized letter should be of the same size as non-capitalized, and just replaces it. I'm not quite sure it's always the case, but should be for most common usages if the first character is a Letter.

@paganotoni paganotoni merged commit 64ac02e into gobuffalo:master Aug 28, 2020
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.

2 participants