像这样我想
// set locale encoding ISO-8859-2
// pl_PL for Linux
// polish_Poland.28592 for Windows
if (PHP_OS == 'WINNT') {
setlocale(LC_ALL, 'polish_Poland.28592');
} else {
setlocale(LC_ALL, 'pl_PL');
}
用于设置成UTF-8
<?php
$codeset = "UTF8"; // warning ! not UTF-8 with dash '-'
// for windows compatibility (e.g. xampp) : theses 3 lines are useless for linux systems
putenv('LANG='.$lang.'.'.$codeset);
putenv('LANGUAGE='.$lang.'.'.$codeset);
bind_textdomain_codeset('mydomain', $codeset);
// set locale
bindtextdomain('mydomain', ABSPATH.'/locale/');
setlocale(LC_ALL, $lang.'.'.$codeset);
textdomain('mydomain');
?>
其中locale的目录结构是(举例来说): 区域设置/ fr_FR目录/ LC_MESSAGES/mydomain.mo locale/en_US/LC_MESSAGES/mydomain.mo
和ABSPATH是区域设置目录的绝对路径
进一步说明,在linux系统下,似乎有必要使用'locale-gen'在os级别创建语言环境。
好的,但如果我想要整个UTF8字符集?或者这真的只是一个区域代码,我必须选择一个? – 2011-02-03 15:33:35