Skip to content

Conversation

alexdowad
Copy link
Contributor

The 'h' flag makes mb_convert_kana convert zenkaku hiragana to hankaku katakana; 'k' makes it convert zenkaku katakana to hankaku katakana.

When working on the implementation of mb_convert_kana, I added some additional checks to catch combinations of flags which do not make sense; but there is no conflict between 'h' and 'k' (they control conversions for two disjoint ranges of codepoints) and this combination should not have been restricted.

Thanks to the GitHub user 'akira345' for reporting this problem.

Closes GH-10174.

FYA @cmb69 @youkidearitai

@youkidearitai
Copy link
Contributor

Looks good to me.

@nikic
Copy link
Member

nikic commented Dec 29, 2022

I'd suggest to also add a positive test for the flag combination.

@alexdowad
Copy link
Contributor Author

@nikic Nice to see you are still around!

The 'h' flag makes mb_convert_kana convert zenkaku hiragana to hankaku
katakana; 'k' makes it convert zenkaku katakana to hankaku katakana.

When working on the implementation of mb_convert_kana, I added some
additional checks to catch combinations of flags which do not make
sense; but there is no conflict between 'h' and 'k' (they control
conversions for two disjoint ranges of codepoints) and this combination
should not have been restricted.

Thanks to the GitHub user 'akira345' for reporting this problem.

Closes phpGH-10174.
@alexdowad
Copy link
Contributor Author

Have just added the test case from GH-10174. Looks good?

Copy link
Member

@cmb69 cmb69 left a comment

Choose a reason for hiding this comment

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

Looks good to me. Thank you!

@alexdowad alexdowad closed this Dec 29, 2022
@alexdowad alexdowad deleted the kanafix branch December 29, 2022 18:39
@alexdowad
Copy link
Contributor Author

Thanks, all. Merged.

@cjayalmontecm
Copy link

cjayalmontecm commented Dec 13, 2024

Hello @alexdowad @cmb69 , I encountered this issue Fatal error: Uncaught ValueError: mb_convert_kana(): Argument #2 ($mode) must not combine 'H' and 'K' flags , it is working on the previous version but not on PHP 8.2 . May I know if this expected result on 8.2?
image

@youkidearitai
Copy link
Contributor

Yes, this is expected behavior. Combination of H and K is impossible.

H is 「半角カタカナ」(half-width katakana) to 「全角カタカナ」(full-width katakana).
K is 「半角カタカナ」(half-width katakana) to 「全角ひらがな」(full-width hiragana).

@alexdowad
Copy link
Contributor Author

Thanks so much, @youkidearitai.
Indeed, it is impossible for mb_convert_kana to obey both the H and K directives at the same time. In older versions, some such conflicts were quietly ignored (one of the conflicting directives would override the other). Now an error is raised to alert the programmer.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

mb_convert_kana is broken in PHP8.2.0

5 participants