In general, such a thing, there is a website encoded in windows-1251 and a base encoded in utf-8, the server successfully recodes everything in windows-1251, but Arabic text in names and surnames began to appear in the database, and the name is displayed on the site after recoding ????????? ????????? I had 2 options for solving this problem

  1. Display names and surnames by frame where iframe is in another encoding (utf-8)
  2. Make ajax request and change data after page load

I think there is a more elegant solution can someone tell me

ps: You cannot completely change the encoding in the database or on the site

a little later a solution was found, but I also do not consider it ideal

<meta charset="windows-1251"> <script type="text/javascript" src="http://code.jquery.com/jquery-1.11.0.min.js"></script> <script> $(function(){ var tmp = decodeURIComponent($('div').html()); console.log(tmp); $('.test').html(tmp); }) </script> <?php $textw = 'text ั‚ะตะบัั‚ windows'; $textw = iconv('UTF-8',"windows-1251//TRANSLIT",$textw); $text = urlencode ('DIMA IVANOV dima ivanov ุจูุณู’ู…ู ุงู„ู„ู‘ู‡ู ุงู„ุฑู‘ูŽุญู’ู…ู†ู ุงู„ุฑู‘ูŽุญููŠู…ู'); echo $textw .'<div>'. $text.'</div><div class="test"></div>'; 
  • The server recodes everything through iconv ? - Mr. Black
  • yes server recodes everything via iconv - baneling
  • I guess the mysql database, there are options "SET NAMES 'cp1251'" , for php mb_internal_encoding('cp1251'); and also specify the encoding in the header header('Content-type: text/html; charset=windows-1251'); Maybe some of this will help. I have not encountered such problems yet, I have a base and website in 1251, scripts in utf8 and no problems - Mr. Black
  • in cp1251 there are no Arabic characters in this and there lies the problem - baneling
  • An elegant solution is to switch completely to UTF-8 and not crush the crutches. - Visman

2 answers 2

In 1251, no one has been working for a long time. Arabic characters in 1251 does not exist. Convert all the site files to UTF-8 and do not bother with the iframe in a different encoding.

    It is better to recode the entire site to UTF-8, but you can encode missing characters into windosw-1251 using the mb_encode_numericentity() function

     echo mb_encode_numericentity($text, array(0x80, 0xffff, 0, 0xffff), 'UTF-8');