- 追加された行はこの色です。
- 削除された行はこの色です。
#author("2022-07-14T08:07:02+00:00","default:admin","admin")
#author("2022-07-14T09:13:08+00:00","default:admin","admin")
*機種依存文字 [#gb762021]
-[[機種依存文字 - Wikipedia:https://ja.wikipedia.org/wiki/%E6%A9%9F%E7%A8%AE%E4%BE%9D%E5%AD%98%E6%96%87%E5%AD%97]]
-[[機種依存文字について - 農林水産省:https://www.maff.go.jp/j/use/kisyu_izon.html]]
-[[代表的な機種依存文字一覧:https://mect-japan.com/2019/guide/izon.html]]
-[[【php】はしご高が文字化けしない文字コード変換:https://www.softel.co.jp/blogs/tech/archives/5145]]
-[[PHPでPCの機種依存文字を検出し、変換(削除)する。:https://pgmemo.tokyo/data/archives/978.html]]
**機種依存文字の判定 [#re0bb74b]
-[[フォームのバリデーションでよく使う項目をまとめた小話:https://blog.8bit.co.jp/?p=19649#i-2]]
--機種依存文字をShift-JISに変換してからUTF-8に戻した場合、元の文字と異なるので、そこでエラーを出す
***サンプルコード [#n7d9352d]
<?php
//---- 機種依存文字:あり ----
$strText = "髙橋";
//$strText = "㈱あいうえお";
//$strText = "№㏍℡㊤㊥㊦㊧㊨㈱㈲㈹㍾㍽㍼㍻";
//$strText = "㍉ ㎜ ㎝ ㎞ ㎎ ㎏ ㏄㍉㌔ ㌢ ㍍㌘ ㌧ ㌃ ㌶ ㍑㍗ ㌍ ㌦ ㌣ ㌫ ㍊ ㌻";
//$strText = "①②③④⑤⑥⑦⑧⑨⑩⑪⑫⑬⑭⑮⑯⑰⑱⑲⑳";
//$strText = "ⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩ";
//$strText = "¥$¢£%‰℃Å";
//$strText = "ⅠⅡⅢⅣⅤ≡∑∫∮√⊥∠∟⊿∵∩∪・";
//$strText = "纊鍈蓜炻棈兊夋奛奣寬﨑嵂";
//---- 機種依存文字:なし ----
//$strText = "高橋";
//$strText = "ハンカクカタカナ";
//$strText = "〇○◇□△▽☆●◆■▲▼★◎◯♂♀〒";
//$strText = "→←↑↓⇒⇔";
//$strText = "…‥、。,.・:;?!゛゜´`¨^ヽヾゝゞ〃°′″";
//$strText = "+-±×÷=≒≠≦≧<≪≫∞∽∝∴∵∈∋⊆⊇⊂⊃∪∩∧∨⇒⇔∀∃∠⊥⌒∂∇≡√∫∬";
//$strText = "ΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩαβγδεζηθικλμνξοπρστυφχψω";
//$strText = "АБВГДЕЁЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдеёжзийклмнопрстуфхцчшщъыьэюя";
//$strText = "─│┌┐┘└├┬┤┴┼━┃┏┓┛┗┣┳┫┻╋┠┯┨┷┿┝┰┥┸╂";
//$strText = "#&*@§※〓♯♭♪†‡¶仝々〆ー~ ̄_―‐∥|/\";
if (checkU2S($strText)) {
echo "機種依存文字が入ってます\n";
} else {
echo "機種依存文字は入っていません\n";
}
function checkU2S($s){
$mb_encode = mb_detect_encoding($s);
if ($mb_encode == "UTF-8") {
return strlen($s) !== strlen(mb_convert_encoding(mb_convert_encoding($s,'sjis','UTF-8'),'UTF-8','sjis'));
} else {
return strlen($s) !== strlen(mb_convert_encoding(mb_convert_encoding($s,'sjis-win','UTF-8'),'UTF-8','sjis-win'));
}
}
?>
*Unicode文字 [#lcfc8136]
-[[【Sqlserver】【Access】文字化けの原因は、環境依存文字じゃなくUnicode文字!?:https://pctips.jp/pc-soft/unicode-moji/]]