I get the post request with the data in the utf-8 encoding and write them in the database, but all the data in the database should be stored in cp1251 encoding, as a result, the data that comes in the post request and entered into the database will look like questions, how to change it in perl the encoding of the incoming data (or more simply, how to change the encoding of the string to cp1251)?
There is a module Encode and its function of the same name encode. Convert the string to cp-1251 and only after add it to the database. Check what encoding matches the data in the database; it should also be specified as cp-1251. And yes, also check the mysql_enable_utf flag; when connecting to the database from the script, it can be forced to be raised, which is not necessary in your case.
And what will you do with characters missing in CP1251? Maybe it's better to still store data in a database in UTF-8?
If the base is MySQL, then the encoding can be performed by means of the DBMS itself: MySQL (if it is not ancient 3.23. *) Allows you to store data in one encoding (and in CP1251), and communicate between the server and the client in another. You can switch the encoding in which data is transmitted in various ways, including the
SET NAMES command:
-- Передаваемые данные — в UTF-8 SET NAMES utf8;
Convert::Cyrillic , even
Encode::from_to fit, a lot of options. But this is a very bad idea :(