Last active
June 19, 2018 11:10
-
-
Save tanakahisateru/b9e4e65502282b08a83a2c74baff446d to your computer and use it in GitHub Desktop.
入力した波ダッシュが全角チルダに化けるまたはその逆について
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$wave = "\u{301C}"; | |
$tilde = "\u{FF5E}"; | |
// EUC-JP has no different character for wavy dash and full width tilde | |
$eucWave = mb_convert_encoding($wave, 'euc-jp', 'utf-8'); | |
$eucTilde = mb_convert_encoding($tilde, 'euc-jp', 'utf-8'); | |
assert($eucWave == $eucTilde); | |
// euc-jp to utf-8: always wavey dash | |
$revertedEucWave = mb_convert_encoding($eucWave, 'utf-8', 'euc-jp'); | |
$revertedEucTilde = mb_convert_encoding($eucTilde, 'utf-8', 'euc-jp'); | |
assert($revertedEucWave == $wave); | |
assert($revertedEucTilde == $wave); | |
// eucJP-win to utf-8: always full width tilde | |
$revertedEucWinWave = mb_convert_encoding($eucWave, 'utf-8', 'eucJP-win'); | |
$revertedEucWinTilde = mb_convert_encoding($eucTilde, 'utf-8', 'eucJP-win'); | |
assert($revertedEucWinWave == $tilde); | |
assert($revertedEucWinTilde == $tilde); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment