The module comments in the profile. A message with Russian characters is displayed empty, but with a Latin alphabet it is normal. I tried different versions everywhere the same, help.

site encoding Windows-1251

All files of the Windows-1251 module

the table in the database is also cp1251_general_ci

A piece of code in the module responsible for the encoding

if ($_POST['ajax'] == 1) { function echoReturn($text) { die("<script language=\"javascript\">alert('{$text}');</script>"); } if (!function_exists("CharsetConvert")) { function CharsetConvert($text, $to = "auto") { global $config; if (version_compare($config['version_id'], "7.5", "<")) return convert_unicode($text); $text = stripslashes($text); $charset = mb_detect_encoding($text, "utf-8,windows-1251"); if ($to == "auto") $to = $config['charset']; if ($charset != $to && $to != "") $text = iconv($charset, $to . "//IGNORE", $text); return urldecode($text); } } if (!$is_logged) die($lang["lang_wall_1"]); $UserID = intval($member_id['user_id']); $UserName = stripslashes($member_id['name']); if ($_POST['add'] == 1) { $text = trim(htmlspecialchars(CharsetConvert(stripslashes($_POST['text'])))); 
  • Check the database, it should support encoding when connected - L. Vadim
  • How to check the database? - steep
  • @steep, please tell me, how does the above piece of code refer to the output of comments? The given piece of code, as far as I understand, decodes the comments received via XHR (Ajax). The simplest way is to connect to the database and see what is in the database and determine where the problem is: when saving the comments or when they are output. - Mikhail Rebrov
  • There is no comment in the database either. Where can I write all the code, is it not small? - steep

1 answer 1

You must explicitly specify the encoding (the third parameter).

The last line in my code, change to this.

 $text = trim(htmlspecialchars(CharsetConvert(stripslashes($_POST['text'])), ENT_COMPAT, "windows-1251"));