A
A
Alexander Sinitsyn2018-02-23 01:31:34
MySQL
Alexander Sinitsyn, 2018-02-23 01:31:34

What encoding to choose for the base so that you can save strings in any language and not soar your brain?

Made a migration
$tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB';
I added a model, I send post data with Cyrillic, save () works, but the Latin gets into the database, and there is an empty space from the Cyrillic ... I'm afraid to guess what will happen if someone writes in Arabic, Chinese or Hindi. What to do?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
K
Kirill Nesmeyanov, 2018-02-23
@a_u_sinitsin

It is worth setting utf8mb4_unicode_ci everywhere (it works more accurately when sorting, etc.) or utf8mb4_general_ci (it works a little faster, extremely slightly, so the first option makes sense).
PS The above utf8_general_ci/utf8_unicode_ci support only half of the utf8 range, hence saving, for example, emoji, will be physically impossible.
PPS The "ci" suffix means Case Insensitive (case insensitive when searching and comparing).

M
mitaichik, 2018-02-23
@mitaichik

Usually utf8_general_ci like

D
Denis, 2018-03-09
@sidni

Your normal encoding, utf8_unicode_ci is also suitable for Cyrillic. Maybe something happens during json decoding or you use string functions without the mb_ prefix

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question