全角・半角

変換

mb_convert_kana

機種依存文字

機種依存文字の判定

サンプルコード

<?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文字


トップ   編集 凍結 差分 バックアップ 添付 複製 名前変更 リロード   新規 一覧 単語検索 最終更新   ヘルプ   最終更新のRSS
Last-modified: 2022-10-28 (金) 17:42:41 (543d)