Evgenii Legotckoi
Evgenii LegotckoiJune 4, 2017, 4:52 a.m.

Correcting the client encoding of the PostgreSQL database from LATIN1 to UTF8

Content

On the site there was one bug that manifested itself when trying to attach to files messages whose names were in Cyrillic. In this case, the site issued error 503. This occurred despite the fact that the database was encoded in UTF8, after correcting the encoding of the database itself in the previous article . While Django issued the following message:

'latin-1' codec can't encode characters in position 55-64: ordinal not in range(256)

The problem was that the server's coding was initially set to LATIN1. That is, the following commands gave the following conclusion:

postgres=# show server_encoding;
 server_encoding 
-----------------
 LATIN1
(1 row)

postgres=# show client_encoding;
 client_encoding 
-----------------
 LATIN1
(1 row)

postgres=# \encoding 
 LATIN1

Executing the command SET CLIENT_ENCODING TO 'utf 8'; did not work, after exiting psql, the encoding was returned to LATIN1 .


Correction

Correction of this bug reduced to setting the encoding of the server itself. Since the server is primarily Russian-speaking, the installation of Russian-language packages of locales was made to correct it.

sudo apt-get install language-pack-ru

Implementation of the Russification process

sudo update-locale LANG=ru_RU.UTF-8

And reboot the server

sudo reboot

After that, the server client encoding became UTF8

postgres=# show server_encoding;
 server_encoding 
-----------------
 LATIN1
(1 row)

postgres=# show client_encoding;
 client_encoding 
-----------------
 UTF8
(1 row)

postgres=# \encoding 
 UTF8

This was enough to fix the bug.

We recommend hosting TIMEWEB
We recommend hosting TIMEWEB
Stable hosting, on which the social network EVILEG is located. For projects on Django we recommend VDS hosting.

Do you like it? Share on social networks!

Comments

Only authorized users can post comments.
Please, Log in or Sign up
AD

C ++ - Test 004. Pointers, Arrays and Loops

  • Result:50points,
  • Rating points-4
m

C ++ - Test 004. Pointers, Arrays and Loops

  • Result:80points,
  • Rating points4
m

C ++ - Test 004. Pointers, Arrays and Loops

  • Result:20points,
  • Rating points-10
Last comments
i
innorwallNov. 14, 2024, 6:09 a.m.
Qt/C++ - Tutorial 068. Hello World using the CMAKE build system in CLion ditropan pristiq dosing With the Yankees leading, 4 3, Rivera jogged in from the bullpen to a standing ovation as he prepared for his final appearance in Chicago buy priligy pakistan
i
innorwallNov. 14, 2024, 1:05 a.m.
EVILEG-CORE. Using Google reCAPTCHA 2001; 98 29 34 priligy buy
i
innorwallNov. 14, 2024, 1 a.m.
PyQt5 - Lesson 007. Works with QML QtQuick (Signals and slots) priligy 30mg Am J Obstet Gynecol 171 1488 505
i
innorwallNov. 13, 2024, 11:54 p.m.
Django - Tutorial 003. Model, Template, View on Django Hair follicles are believed to produce approximately 20 individual hair shafts over the life of the follicle as the follicle progresses through cycles of hair production, shedding ejection, invo…
i
innorwallNov. 13, 2024, 8:03 p.m.
How to make game using Qt - Lesson 3. Interaction with other objects what is priligy tablets What happens during the LASIK surgery process
Now discuss on the forum
i
innorwallNov. 14, 2024, 12:39 a.m.
добавить qlineseries в функции priligy amazon canada 93 GREB1 protein GREB1 AB011147 6
i
innorwallNov. 11, 2024, 7:55 a.m.
Всё ещё разбираюсь с кешем. priligy walgreens levitra dulcolax carbs The third ring was found to be made up of ultra relativistic electrons, which are also present in both the outer and inner rings
9
9AnonimOct. 25, 2024, 6:10 a.m.
Машина тьюринга // Начальное состояние 0 0, ,<,1 // Переход в состояние 1 при пустом символе 0,0,>,0 // Остаемся в состоянии 0, двигаясь вправо при встрече 0 0,1,>…

Follow us in social networks