【发布时间】:2014-09-11 07:00:08
【问题描述】:
我有一个用 PHP 读取的属性文件。该属性看起来像这样:
destination = "bibliothèque"
然后,我想将该属性读取为 UTF-8。
function utf8_trim($str) {
return preg_replace("/^[\p{Z}\p{Cf}\x{200e}\x{200f}\s]*([\s\S]*?)[\p{Z}\p{Cf}\x{200e}\x{200f}\s]*$/u", "$1", $str);
}
mb_internal_encoding("UTF-8");
$places = parse_ini_file($filename);
$destination_untrimmed = $places['destination'];
$destination = utf8_trim($destination_untrimmed); //FAILS on this step due to invalid encoding
我使用的是 Eclipse 3.8.1。如何将我的字符串以 UTF-8 格式输入到常量文件中?
【问题讨论】:
标签: php eclipse utf-8 preg-replace properties-file