- r - 以节省内存的方式增长 data.frame
- ruby-on-rails - ruby/ruby on rails 内存泄漏检测
- android - 无法解析导入android.support.v7.app
- UNIX 域套接字与共享内存(映射文件)
我一直在阅读用户对 strtoupper() PHP 函数的评论,但似乎没有就如何对非英语字符串进行转换达成共识。我的意思是人们提供本地化的解决方案和东西,但难道不应该有一种统一的方法来将字符串转换为所有大写(或所有小写)字母吗?
所以我的问题是,比方说,如果我有一个 UTF-8 编码的字符串(在某些未知的语言环境中),我如何将它转换为 PHP 中的所有大写/小写字母?
最佳答案
您想使用 mb_strtoupper
。
$str = "Τάχιστη αλώπηξ βαφής ψημένη γη, δρασκελίζει υπέρ νωθρού κυνός";
$str = mb_strtoupper($str, "UTF-8");
echo $str; // Prints ΤΆΧΙΣΤΗ ΑΛΏΠΗΞ ΒΑΦΉΣ ΨΗΜΈΝΗ ΓΗ, ΔΡΑΣΚΕΛΊΖΕΙ ΥΠΈΡ ΝΩΘΡΟΎ ΚΥΝΌΣ
PHP.net状态:
By contrast to the standard case folding functions such as strtolower() and strtoupper(), case folding is performed on the basis of the Unicode character properties. Thus the behaviour of this function is not affected by locale settings and it can convert any characters that have 'alphabetic' property, such as A-umlaut (Ä).
关于php - UTF-8 字符串的 strtoupper PHP 函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5969803/
我有一小段代码想大写。 $box = mysql_real_escape_string(strtoupper($_POST['box'])); 出于某种原因,它没有将其变成大写。难道是因为帖子是字母和
1,将字符串转换成小写 strtolower函数: 该函数将传入的字符串参数所有的字符都转换成小写,并以小定形式放回这个字符串。 例子: ?
出于好奇,我做了一个实验。我想看看 strtolower() 之间是否存在细微差异和 strtoupper() .我期待 strtolower()在大多数小写字符串上会更快,反之亦然。我发现的是 st
我目前在一个 GREEK 项目中工作。在那个项目中,所有内容都是希腊语,并且我有一个搜索功能。搜索过程很好。但是 strtoupper() 没有将希腊语转换为大写,而 strtolower() 没有将
我一直在阅读用户对 strtoupper() PHP 函数的评论,但似乎没有就如何对非英语字符串进行转换达成共识。我的意思是人们提供本地化的解决方案和东西,但难道不应该有一种统一的方法来将字符串转换为
我们正在处理一个以前从未发生过的 Joyent Solaris 服务器中的奇怪错误(不会发生在本地主机或其他两个具有相同 php 配置的 Solaris 服务器中)。其实我也不确定是要看php还是so
我是一名优秀的程序员,十分优秀!