Answer the question
In order to leave comments, you need to log in
Why is windows-1251 encoded string not saved to mysql database with utf8mb4 encoding?
I upload a txt file to the server, extract text from the file, and try to save this text to the database.
I am uploading a file in windows-1251 encoding, when saving the text to the database, an error occurs
SQLSTATE[HY000]: General error: 1366 Incorrect string value: '\xF0\xF3\xF1\xF1\xEA\xE8...' for column 'content ' at row 1
I don't quite understand how to work with different encodings.
Why is there an error? In utf-8, 4 bytes are allocated per character, in windows-1251 it seems to be exactly less.
According to the task, the texts can be in any language and in any encoding. How can this be implemented? Make the content blob field?
Converting from one encoding to another is not an option, as the encoding of the text will always be unknown.
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question