To convert UTF-8 to Latin-1?

0 like 0 dislike
69 views
A PHP script receives from the client a text in utf8 encoding. Encoding puts Jquery. On the server side, you need to convert the text encoding for Latin-1 (used in the database, change not).


Used iconv:

iconv('UTF-8', 'LATIN-1', $text);


Instead of Latin-1 and tried LATIN1, ISO-8859-1, but still output an empty line. Suggested solutions:

— How to get JQuery to send the text to the desired encoding (on the client page ISO-8859-1). But in General the place is somehow encoded for compatibility (like Russian letters in the URL), so that this path is fraught with problems (or not?).

To solve the problem of the lack of encoding / impossible to convert it from utf8.

To pick up a similar set (in extreme cases).


Maybe someone solved a similar problem. I would be very grateful as the Internet is very stingy on the hints :).


UPD:

Interesting, but doesn't work for me:
stackoverflow.com/questions/374425/convert-utf8-ch...
by | 69 views

5 Answers

0 like 0 dislike
Try this:
\r
mb_convert_encoding($text, 'HTML-ENTITIES', 'UTF-8');
by
0 like 0 dislike
I usually work this option:
\r
$converted = mb_convert_encoding($src_string, 'UTF-8', mb_detect_encoding($src_string));
\r
by
0 like 0 dislike
Might be worth a try to set the encoding when connecting?
set names latin1
by
0 like 0 dislike
1. try iconv LATIN1
2. try to convert the dB level insert into tbl sel pole=CONVERT(_latin1'Müller' USING utf8)
by
0 like 0 dislike
As far as I understand, You are working with AJAX, and I suspect that send a fairly complex data structure. If so, then You will not be able to find the correct option — it is not. Some browsers behave unacceptably despite all the tricks.
\r
Although you can try. For the proper functioning:
— custom php to work in latin (or whatever you need),
— all incoming data is processed iconv
just in case set the encoding of the interaction with the database
by

Related questions

0 like 0 dislike
2 answers
asked Apr 9, 2019 by serii81
0 like 0 dislike
2 answers
0 like 0 dislike
2 answers
asked Apr 9, 2019 by teremok995
0 like 0 dislike
2 answers
0 like 0 dislike
4 answers
110,608 questions
257,186 answers
0 comments
28,647 users