我有两个字符串变量 - 第一个变量是在代码($date1="14 июня"
)中手动设置的,第二个是使用cURL和phpQuery从远程页面解析的。
如果我们打印两个变量,结果看起来都一样,但长度和内容是不同的:
echo $date1; //output: 14 июня
echo $date2; //output: 14 июня
echo $date1[2]; //output is space - third symbol in string
echo $date2[2]; //output is � - it's a part of third symbol in string
echo strlen($date1); //output: 7
echo strlen($date2); //output: 12
echo mb_detect_encoding($date1) //output: UTF-8
echo mb_detect_encoding($date2) //output: UTF-8
我想知道是否有解决方案如何将$date2
转换为$date1
的格式/编码?
p.s:有关于iconv()的SO主题,但我找不到合适的解决方案。