Hob*_*Ben 15 php encoding utf-8 character-encoding latin1
我想禁止某些UTF-8输入(服务器端),例如东方语言,其中示例输入可能是"伊".
但是,我确实想继续支持其他拉丁语或"拉丁语"字符,例如威尔士语ŵ和ŷ,因此无法检查拉丁语1.
我有什么选择?(如果语言特定,PHP首选)
非常感谢.
推理:很多非西方角色的浏览器支持经常丢失(例如在不同的浏览器上我只看到上面问题中的一个框),所以对于像显示名称这样的东西,有时候限制它是合适的,即使它不适合消息体
Art*_*cto 34
做就是了
preg_match('/[^\\p{Common}\\p{Latin}]/u', $string)
Run Code Online (Sandbox Code Playgroud)
哪里$string是UTF-8字符串.如果有非拉丁字符,则返回"1",否则返回"0".
例:
var_dump(preg_match('/[^\\p{Common}\\p{Latin}]/u', 'sf..?aás??')); //int(0)
var_dump(preg_match('/[^\\p{Common}\\p{Latin}]/u', 'sf..??aás??')); //int(1)
Run Code Online (Sandbox Code Playgroud)