我正在处理ISO-3166中的国家名称文本文件,以便将国家名称提取到一个数组中。问题是,当我输出数组时,某些国家/地区的特殊字符丢失或更改:
$country_1 = fopen("./country_names_iso_3166.txt", "r");
while( !feof($country_1) ) { // go through every line of file
$country = fgets( $country_1 );
if( strstr($country, ",") ) // if country name contains a comma
$i = strpos( $country, "," ); // index position of comma
else
$i = strpos( $country, ";" ); // index position of semicolon
$country = substr( $country, 0, $i ); // extract just the country name
$countries[] = $country;
}因此,现在当我输出数组时,例如,第二个国家名称应该是奥兰岛,但它输出为陆地岛……请建议如何解决此问题。
发布于 2011-07-11 23:52:49
请尝试使用支持多字节的字符串函数。mb_strstr()、mb_strpos()、mb_substr() (基本上只是前缀mb_)。
发布于 2011-07-11 23:34:07
确保输出数据的流使用与输入文件相同的字符集。
(删除了说ISO-3166是字符集的错误)
https://stackoverflow.com/questions/6652597
复制相似问题