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 .kana_to_roma method to prevent .romaji from modifying pre-existing alpha chars in a string #6

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

johnnyshields
Copy link
Contributor

I found an edge-case where the .romaji method can affect some pre-existing alpha chars in the string, for example two consective ns become a single n. (There are a few other cases as well).

"runner ツクエ".romaji #=> "runer tsukue"

To workaround this, I added a new method .kana_to_roma which breaks up the string into kana and non-kana chunks, and calls .romaji only on the kana chunks.

"runner ツクエ".kana_to_roma #=> "runner tsukue"

I think it might actually be better to make this the behavior of the .romaji method itself, as in nearly every case I'd think users wouldn't want to affect existing alpha chars.

I think we need to do something here because current behavior is unexpected--I was actually calling it on email addresses to sanitize them, and it was breaking the emails!

…od where it modifies pre-existing alpha chars in the string.
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.

1 participant