- 论坛徽章:
- 0
|
我想写一个程序,不管当前登陆的是什么locale都可以打印出各个别的locale的文件或日期格式。
我试过setlocale可是没管用:
代码:
++++++++++++++++++
bash-3.00# more localeset.pl
#!/usr/bin/perl
use POSIX qw(locale_h);
setlocale(LANG,"zh_CN.EUC");
print setlocale(LANG);
print "\n";
open(EUCFile,"copyright.euc");
@copyrights=<EUCFile>;
print "copyright.enc-----------begin\n";
foreach $copyright (@copyrights){
print $copyright;
}
print "copyright.enc-----------end.\n/\n/\n";
setlocale(LANG,"zh_CN.UTF-8");
print setlocale(LANG);
print "\n";
open(UTFFile,"copyright.utf8");
@copyrights=<UTFFile>;
print "copyright.utf8-----------begin.\n";
foreach $copyright (@copyrights){
print $copyright;
}
print "copyright.utf8-----------end.\n";
close(UTFFile);
++++++++++++++++++
结果:
++++++++++++++++++
bash-3.00# ./localeset.pl
zh_CN.EUC
copyright.enc-----------begin
版权所有 (c) 1990-2005 VERITAS Software Corporation。
保留所有权利。VERITAS 及 VERITAS 徽标均为 VERITAS Software
Corporation 及其附属机构在美国以及其他国家/地区的商标或注册
商标。其他名称可能是各自所有者的商标。
copyright.enc-----------end.
/
/
zh_CN.UTF-8
copyright.utf8-----------begin.
(c) 1990-2005 VERITAS Software Corporation
淇┿VERITAS VERITAS 寰芥涓 VERITAS Software
Corporation 堕灞烘ㄧ戒互朵藉?/板虹娉ㄥ
朵绉板?芥??
copyright.utf8-----------end.
++++++++++++++++++ |
|