Search code examples
phpwordpressconverterstaxonomy

Japanese Format


In WordPress When I read a tag from taxonomy by Japanese, it like this '日本語' but this is the result %e6%97%a5%e6%9c%ac%e8%aa%9e. I have compared it with right text. It become true.

if(strcmp($row[$header][$i]['slug'], '日本語'))

I would like to write csv file which using Japanese Characters . how could I convert %e6%97%a5%e6%9c%ac%e8%aa%9e to '日本語'.


Solution

  • Use urldecode to invert:

    $string = urldecode('%e6%97%a5%e6%9c%ac%e8%aa%9e'); // Converts to 日本語
    

    SEE DEMO.

    You can use urlencode method to compare and strcasecmp for case-insensitive comparision:

    if( strcasecmp($row[$header][$i]['slug'], urlencode('日本語')) )
    

    SEE DEMO.