Avoid warnings for and detect the problem.

If the string is not posible to encode, send a warning to screen, and is dificult to find.
 Warning: json_encode(): Invalid UTF-8 sequence in argument occurred