12
I need a function or class that ensures that data sent from a form (from anywhere in the world) go to the bank in UTF-8 encoding.
I tried to, $string = iconv(mb_detect_encoding($text), "UTF-8", $text);
but has problems (if the input is 'nation' it returns 'in').
I tried to $string = mb_convert_encoding($text, "UTF-8");
but also has problems returns no§
gave 2 errors PHP Warning: Unexpected Character in input: '' (ASCII=92) state=1 in.... on line 4 PHP Parse error: syntax error, Unexpected T_STRING, expecting T_CONSTANT_ENCAPSED_STRING .... on line 4 Line 4= use Forceutf8 Encoding;
– user60252
I edited the answer with an option that might work in your case.
– William Novak
PHP Warning: Unexpected Character in input: '' (ASCII=92) state=1 in ..... PHP Parse error: syntax error, Unexpected T_STRING, expecting ',' or ';' ... on line 8 Line 8 >> echo Forceutf8 Encoding::fixUTF8("Naã§");
– user60252
echo Encoding::fixUTF8("Naã§Ã"); and gave error PHP Parse error: syntax error, Unexpected T_STRING in .... Encoding.php on line 36 On line 36 of the Encoding file we have namespace Forceutf8;
– user60252
@Leo Caracciolo What’s your version
PHP
?– William Novak
@ William Novak Version 5.2.17 .... ;)
– user60252
Leo, unfortunately
namespaces
is only available in versions>=
5.3
ofPHP
.– William Novak