Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/252.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 用PHP解码unicode转义字符_Java_Php_Unicode_Encoding_Decoding - Fatal编程技术网

Java 用PHP解码unicode转义字符

Java 用PHP解码unicode转义字符,java,php,unicode,encoding,decoding,Java,Php,Unicode,Encoding,Decoding,我有多个文本文件将应用程序翻译成不同的语言。这些文本文件来自Java应用程序,如下所示: weather_501=m\u00E4ßiger Regen weather_701=tr\u00FCb weather_731=Sand / Staubsturm weather_802=\u00FCberwiegend bew\u00F6lkt 我使用以下PHP函数加载此文件,$locale是输出的语言: function loadTranslation($locale) { $this-&g

我有多个文本文件将应用程序翻译成不同的语言。这些文本文件来自Java应用程序,如下所示:

weather_501=m\u00E4ßiger Regen
weather_701=tr\u00FCb
weather_731=Sand / Staubsturm
weather_802=\u00FCberwiegend bew\u00F6lkt
我使用以下PHP函数加载此文件,
$locale
是输出的语言:

function loadTranslation($locale) {
    $this->_data = array();
    $localeFilePath = PATH_LANG . '/text/textTx_' . $locale . '/properties';

    if (file_exists($localeFilePath)) {
        $localeFileHandle = fopen($localeFilePath, "r");        
        while (($line = fgetcsv($localeFileHandle, 1000, "=")) !== FALSE) {
            $this->_data[$line[0]] = $line[1];
            print_r($line);
        }
        fclose($localeFileHandle);
    }
    else echo 'Error: localeFilePath does not exist: '.$localeFilePath.'<br/>';

    return $this;
}
函数加载转换($locale){
$this->_data=array();
$localeFilePath=PATH_LANG.'/text/textTx_.'$locale.'/properties';
如果(文件_存在($localeFilePath)){
$localeFileHandle=fopen($localeFilePath,“r”);
而(($line=fgetcsv($localeFileHandle,1000,“=”)!==FALSE){
$this->_数据[$line[0]]=$line[1];
打印(行);
}
fclose($localeFileHandle);
}
else echo“错误:localeFilePath不存在:”。$localeFilePath。“
”; 退还$this; }
现在的问题是UTF-8的unicode解码/编码。我试了好几次,但都没有成功。例如,它为德国Umlauts工作,但不为像“ß”这样的字符工作。产出“mä�伊格尔再生”。 此外,我没有让
json\u encode
json\u decode
函数工作

也许有人能帮我,告诉我我做错了什么


注意:PHP版本5.5

问题在于文本文件编码错误,原因很简单

文件现在已正确编码,一切正常