Skip to content

Add .kana_to_roma method to prevent .romaji from modifying pre-existing alpha chars in a string#6

Open
johnnyshields wants to merge 1 commit intoikayzo:masterfrom
johnnyshields:master
Open

Add .kana_to_roma method to prevent .romaji from modifying pre-existing alpha chars in a string#6
johnnyshields wants to merge 1 commit intoikayzo:masterfrom
johnnyshields:master

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