PHP `iconv` not working inside a WordPress site

To solve this problem I need to insert this instruction BEFORE iconv:

setlocale( LC_ALL, "pt_BR.UTF-8");

Thus, the conversion is done correctly (in my case, because my site is in pt_BR):

<?php
    $filename = "ação";
    setlocale( LC_ALL, "pt_BR.UTF-8"); // fix the locale
    $filename = iconv( 'UTF-8', 'ASCII//TRANSLIT', $filename); // convert latin characters
    echo $filename; // shows "acao"

Correct result:

acao