- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我有一些带有(瑞士)法语字符的字符串,我想大写(PHP 5.3)。
echo strtoupper('société');
由于 strtoupper()
不适用于重字符,我做了一个 setlocale()
(这个语言环境在我们的 Ubuntu dev 和 debian prod 服务器上可用),它不起作用:
setlocale(LC_CTYPE, 'fr_CH');
echo strtoupper('société');
预期结果:
SOCIÉTÉ
结果:
SOCIéTé
可用语言环境:
$ locale -a
...
fr_CH
fr_CH.iso88591
fr_CH.utf8
fr_FR
fr_FR.iso88591
fr_FR.iso885915@euro
fr_FR.utf8
fr_FR@euro
...
$ locale
LANG=
LANGUAGE=
LC_CTYPE="POSIX"
LC_NUMERIC="POSIX"
LC_TIME="POSIX"
LC_COLLATE="POSIX"
LC_MONETARY="POSIX"
LC_MESSAGES="POSIX"
LC_PAPER="POSIX"
LC_NAME="POSIX"
LC_ADDRESS="POSIX"
LC_TELEPHONE="POSIX"
LC_MEASUREMENT="POSIX"
LC_IDENTIFICATION="POSIX"
LC_ALL=
注意:mbstring
模块不可用。
最佳答案
使用 mb_strtoupper() 函数。 mb_strtoupper($str, 'UTF-8');
http://in3.php.net/manual/en/function.mb-strtoupper.php
strtoupper 不是 unicode 感知的。你应该使用多字节版本的字符串函数
<?php function mb_strtoupper_new($str, $e='utf-8') {
if (function_exists('mb_strtoupper')) {
return mb_strtoupper($str, $e='utf-8');
}
else {
foreach($str as &$char) {
$char = utf8_decode($char);
$char = strtr(char,
"abcdefghýijklmnopqrstuvwxyz".
"\x9C\x9A\xE0\xE1\xE2\xE3".
"\xE4\xE5\xE6\xE7\xE8\xE9".
"\xEA\xEB\xEC\xED\xEE\xEF".
"\xF0\xF1\xF2\xF3\xF4\xF5".
"\xF6\xF8\xF9\xFA\xFB\xFC".
"\xFE\xFF",
"ABCDEFGHÝIJKLMNOPQRSTUVWXYZ".
"\x8C\x8A\xC0\xC1\xC2\xC3\xC4".
"\xC5\xC6\xC7\xC8\xC9\xCA\xCB".
"\xCC\xCD\xCE\xCF\xD0\xD1\xD2".
"\xD3\xD4\xD5\xD6\xD8\xD9\xDA".
"\xDB\xDC\xDE\x9F");
$char = utf8_encode($char);
}
return $str;
}
}
echo mb_strtoupper_new('société');
关于php - Setlocale() 不适用于大写重音字符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10599922/
我正在寻找一种方法来支持不区分大小写 + 重音不区分搜索的良好性能。到目前为止,我们在使用 MSSql 服务器时没有遇到任何问题,在 Oracle 上我们必须使用 OracleText,而现在我们在
这个问题已经有答案了: Trouble with UTF-8 characters; what I see is not what I stored (5 个回答) 已关闭 5 年前。 我刚刚将一个我
我正在寻找一种在 Linux 中使用反引号 (`)/波形符 (~) 键和其他一些键创建键盘快捷键的方法。在理想情况下: 按下波形符没有任何作用 按下波形符的同时按另一个键会触发(可自定义的)快捷方式
我有一个由术语组成的数组,其中一些包含重音字符。我像这样做一个 preg grep $data= array('Napoléon','Café'); $result = preg_grep('~' .
我使用 TextBox 在 DataGridView 中进行过滤 image .这是完美的工作。表格的单元格包含 1250 个拉丁字符。我想搜索忽略单元格中单词的重音。例子。如果是文本框 "knjaz
我在 Vim 中遇到一个奇怪的映射问题。我使用的是 Azerty 键盘。 在我的 .vimrc 中,我有以下命令可以在段落之间快速移动。 nnoremap _ { vnoremap _ { nnore
我尝试读取一个utf8编码的vcf文件,结果是: { "name": "=4A=61=76=69=65=72=20=4C=75=6A=C3=A1=6E", "tel":
我的数据库中有两个表,info 和 comment,它们的结构如下: info (id(int(10)), name(varchar(80)), ...19 other columns.., phon
我使用 QtWebkit 制作了一个应用程序。在同一个 html 页面中,在 Windows 上使用重音符号(西类牙语)时可以正常工作,但在 Linux (Ubuntu) 上则不起作用。 我不明白为什
我有(例如)两个字符串: $a = "joao"; $b = "joão"; if ( strtoupper($a) == strtoupper($b)) { echo $b; } 我希望它是
这个问题在这里已经有了答案: 关闭 10 年前。 Possible Duplicate: invalid multibyte char (US-ASCII) with Rails and Ruby
我重写 URL 以包含用户生成的旅游博客的标题。 我这样做是为了 URL 的可读性和 SEO 目的。 http://www.example.com/gallery/280-Gorges_du_Tod
我最近安装了新的 Windows 10 build 14393,我想使用新的 linux 子系统。所以我决定学习 ncurses,但我找不到如何从 getch 中获取带有重音符的字符的 UTF-8 代
我是一名优秀的程序员,十分优秀!