Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我必须在验证时禁用用户在我的网站中输入的中文、日文、西里尔文(等等)字母(仅服务器端验证)。同时,我希望允许所有带有拉丁重音符号的字符。我使用 symfony 1.1 和 PHP 5.2,当然也使用 utf-8。有什么提示吗?
您可以随时转换为 latin1,然后再转换回来。那将丢弃任何非 latin1 字符。例如。:
$str = utf8_encode(utf8_decode($str));
我想知道你为什么首先想要这个?
如果您需要选择,您将无法避免使用正则表达式和/或创建允许的字符列表。
是的,这既不容易也不容易,但如果你想挑剔字符,你可能需要具体一点。