Problem with accented strings

Asked

Viewed 26 times

1

I’m getting a string in an AJAX, however, if that string have an accent it doesn’t work as it should.

$texto = $_REQUEST['texto_de'];
$texto_escrito = 'AB Construções e Serviços';

if($texto == $texto_escrito){
    echo "igual";
}

I am running the following AJAX in the browser:

http://urlajax.com?texto_de=AB Construções e Serviços

This is causing me problems, because later on in the code I need to run a preg_replace, but he does not identify that the string is equal.

  • 1

    Already made a var_dump($texto) to see what’s in PHP?

  • var_dump($text); //returned string(34) "AB Constructions and Services" var_dump($texto_written); //returned string(31) "AB Constructions and Services"

  • I realized that the problem only happens when I copy and paste the source html text of ajax.

  • When it is the application that runs the ajax it ends up not working, knows some way to standardize everything?

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.