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

iphone - Dismissing a UIAlertView -

intellij idea - Update external libraries with intelij and java -

javascript - send data from a new window to previous window in php -