我运行这个 php 代码:
echo "<br>system locales: ".system('locale -a')."<br><br>";
echo "current locales: ".setlocale(LC_ALL, 0)."<br><br>";
var_dump(setlocale (LC_ALL, 'de_DE.utf8'));
echo "current locales: ".setlocale(LC_ALL, 0)."<br><br>";
echo "accepting german characters?: ".ctype_alpha("äüöß")."<br><br>";
echo "accepting characters in general?: ".ctype_alpha("test")."<br><br>";
echo "rejecting numbers?: ".ctype_alpha("tes2t")."<br><br>";
并得到这个输出:
C C.UTF-8 POSIX de_DE.utf8
system locales: de_DE.utf8
current locales: C
string(10) "de_DE.utf8" current locales: de_DE.utf8
accepting german characters?:
accepting characters in general?: 1
rejecting numbers?
我希望在调用 setlocale (LC_ALL, 'de_DE.utf8') 之后,ctype_alpha 会接受像 äöüß 这样的德语字符,如文档中所述:“如果文本中的每个字符都是来自当前语言环境的字母,则返回 TRUE,否则返回FALSE。 " 但事实并非如此。我在这里做错了什么?
PHP版本是:5.3.10-1ubuntu3.8