character encoding is lost when processing a .txt file of country names with with PHP -



character encoding is lost when processing a .txt file of country names with with PHP -

i processing text file of country names iso-3166 extract country names array. problem when output array, special characters countries lost or changed:

$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 comma $i = strpos( $country, "," ); // index position of comma else $i = strpos( $country, ";" ); // index position of semicolon $country = substr( $country, 0, $i ); // extract country name $countries[] = $country; }

so when output array, example, sec country name should Ă…land islands, outputs land islands... please advise on how prepare this.

try using multibyte-aware string functions instead. mb_strstr(), mb_strpos(), mb_substr() (basically prefix mb_).

php encoding character country

Comments

Popular posts from this blog

java - How to pass parameters between Request-Scoped Controllers? -

string - what is the difference between "some" == "some\0" and strcmp("some","some\0") in c++? -

actionscript 3 - Flex: moving a point with rotation doesnt change the point XY? -