My bad, it has nothing to do with PHP, as John Conde said, the thing was that I forgot the use of json_encode with the exception, and json_encode doesn't like non-utf8 characters, so I had something like:
try
{
throw new Exception('Debes iniciar sesión para esto.', 1);
}
catch (Exception $ex1)
{
echo json_encode(array('message' => $ex1->getMessage()));
}
So, when json_encode detects non-utf8 data it will return NULL, so in order to fix this issue we have to explicity encode the data to utf8 before getting the json like this:
json_encode(array('message' => utf8_encode('Canción.')));
The result will generate a JSON with hex characters formated (i.e \x00), with their respective ASCII code. Sorry for telling it was PHP issue when it was a bad of mine. However, I'll accept the John's answer because he answered correctly and he deserves the credit, but I will also leave mine to provide the real cause of the problem.