L
L
Leopandro2016-04-26 23:36:59
PHP
Leopandro, 2016-04-26 23:36:59

How to convert to utf-8 correctly?

IE sends this text ÑÑакан, it is in the cp-1252 format, if it is allowed to recode on the Lebedev website, then everything is displayed correctly, but when I try to recode on the server
, let's say this:

$items = mb_convert_encoding('ÑÑакаÐ', 'UTF-8', 'cp-1252');

then $items has a completely different value of type ÃÂÃÂðúðÃ. How to solve this problem? Well, or there wed-1251 - it doesn't matter.
I also tried to remove the initial encoding, in general I already tried everything. iso - too
Problem solved by encodeURIComponent() of the text I pass via get.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Maxim, 2016-04-26
@m77x

If "fonts are buggy" in the browser, you can fix it through the .htaccess file
in the meta tags:
If this does not help, then look at the data output from the database:

@mysql_connect($sdd_db_host,$sdd_db_user,$sdd_db_pass);// устанавливаем связь с сервером
@mysql_select_db($sdd_db_name);// переключаемся на нужную нам базу данных

// в какой кодировке получать данные от клиента
@mysql_query('set character_set_client="utf8"');

// в какой кодировке получать данные от БД для вывода клиенту
@mysql_query('set character_set_results="utf8"');

// кодировка в которой будут посылаться служебные команды для сервера
@mysql_query('set collation_connection="utf8_general_ci"');

A
Alexey, 2016-04-26
@alsopub

$items = mb_convert_encoding('ÑÑакаÐ', 'CP1252', 'UTF-8')

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question