- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我正在尝试确定哪些环境或其他因素对使用 TRANSLIT
选项调用 iconv()
的结果有影响。
当通过 Apache 和 CLI 运行时,以下代码在本地对我有不同的结果。
<?php
setlocale(LC_ALL, 'en_GB.UTF-8');
header('Content-type: text/html; charset=utf-8'); // for web
$utf8_string = "Pádraig's naïve café";
echo iconv('UTF-8', 'ASCII//IGNORE//TRANSLIT', $utf8_string);
?>
预期结果:Padraig's naive cafe
Web 浏览器中的结果:(空字符串)
CLI 的结果:P'adraig's naive cafe
在某些系统上,我确实得到了预期的结果,但我无法确定原因。
哪些因素会影响转化,我应该遵循哪些步骤来增加获得良好结果的机会?
最佳答案
语言环境正在影响iconv
音译。但是,您应该阅读 setlocale
Docs 上的警告手册页:
The locale information is maintained per process, not per thread. If you are running PHP on a multithreaded server API like IIS or Apache on Windows, you may experience sudden changes in locale settings while a script is running, though the script itself never called setlocale(). This happens due to other scripts running in different threads of the same process at the same time, changing the process-wide locale using setlocale().
因此您可能设置了语言环境,但它在其他地方发生了变化。只要语言环境完全相同,您就会得到相同的结果。
您可以在此处找到 iconv 的文档和源代码:http://www.gnu.org/software/libiconv/ - 这通常是 PHP 使用的库。
关于php - 哪些因素会影响成功的 iconv() TRANSLIT 转换?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9771886/
The proper divisors of a positive integer, n, are all the positive integers that divide n evenly oth
我有这个命令行 $ sudo find /etc/grub.d | sort | tail -n 1 | xargs sudo cat | wc 我想用一个 sudo 命令执行 $ sudo --so
选项大小策略和拉伸(stretch)因子如何影响小部件的大小? 下图显示了三个不同排列的窗口的预览。对于所有三个窗口 (W1-W3),右侧的小部件是一个 QFrame 小部件,其水平和垂直大小策略设置
每次当我必须重新编码一组变量时,我都会想到 SPSS 重新编码功能。我必须承认这很简单。有一个类似的recode函数在 car包,它可以解决问题,但让我们假设我想用 factor 完成任务. 我有 d
这个问题在这里已经有了答案: Template issue causes linker error (C++) [duplicate] (6 个答案) 关闭 9 年前。 我的问题查了没用所以特地来问
我想使用 Eigen 来计算稀疏矩阵的 cholesky 分解。但是,结果不正确,我找不到原因。我如何获得正确答案? Eigen 中是否实现了特殊例程,利用稀疏矩阵的结构来提高性能(例如,对于下例中的
我正在尝试使 angularjs 应用程序在配置( http://12factor.net/config )方面符合 12 因素。 它应该取决于环境,我不应该看到 development 字样, te
我在我的项目中使用 Soil,我在我的包含目录中添加了 soil,在我的预编译头文件中我包含了“Soil.h”。对于我预编译头中的库,我添加了这个: #pragma comment(lib,"SOIL
在我的 Web 应用程序中,我将所有最终用户的日期信息以 UTC 格式存储在数据库中,在向他们显示之前,只需将 UTC 日期转换为他们选择的时区。 我正在使用此方法将本地时间转换为 UTC 时间(在存
我的申请是 Piwik Server从放置在数百个网站上的跟踪代码接收传入的跟踪数据。当这些跟踪请求进入时,大部分工作负载是每秒向数据库写入数百次。我使用的是带有 JDBC 和 Hibernate 的
我有一个非常简单的 GWT 应用程序,它收集一些数据并在用户单击“提交”时提供确认对话框。我创建了一个 com.google.gwt.user.client.ui.DialogBox,填充它,然后调用
我正在使用 Delphi(2009 年,没关系)和 IBX,并且我正在尝试执行简单的代码: TestSQL.ExecQuery; 在此代码之前,我已检查(也可以在调试器监视中看到)TestSQL.Tr
许多线性代数例程都将常量(例如 alpha 和 beta)作为参数。例如cublas?GEMM执行以下操作: C := alpha*op( A )op( B ) + betaC 假设我将 beta 设
我是一名优秀的程序员,十分优秀!