Good day to all. Htmlspecialchars function does not work

$description = htmlspecialchars($all_array["characteristical"][$index], ENT_QUOTES, 'utf-8') ; 

It seems to be worth it, which would be written to the database in UTF-8, but for some reason it converts the file in utf-8 itself into windows-1251, the line in the database in utf8_general_ci

  • The htmlspecialchars () function cannot convert from one encoding to another! Check in what encoding your data comes in. - Visman

1 answer 1

  1. Check the default_charset parameter in php settings
  2. Best of all, the input data is already in UTF-8