npgsql: encoding problem for exception text
Win x64 System encoding windows-1251 (Russian) Postgresql installed with default encoding.(9.5.3) If connection.open raise exception, this exception has bad text.(wrong symbols) Sorry for english.
{Npgsql.PostgresException: 28P01: ������������ “user” �� ������ �������� ����������� (�� ������) at Npgsql.NpgsqlConnector.DoReadMessage(DataRowLoadingMode dataRowLoadingMode, Boolean isPrependedMessage) at Npgsql.NpgsqlConnector.ReadMessageWithPrepended(DataRowLoadingMode dataRowLoadingMode) at Npgsql.NpgsqlConnector.HandleAuthentication(String username, NpgsqlTimeout timeout) at Npgsql.NpgsqlConnector.Open(NpgsqlTimeout timeout) at Npgsql.ConnectorPool.Allocate(NpgsqlConnection conn, NpgsqlTimeout timeout) at Npgsql.NpgsqlConnection.OpenInternal() at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.Open() at postgre.test.Program.Main(String[] args) in C:\Users\user\Documents\Visual Studio 2015\Projects\speech\postgre.test\Program.cs:line 71}
System .Text.Encoding .ASCII. GetBytes ( ex.Message )
[1]: 56
[2]: 80
[3]: 48
[4]: 49
[5]: 58
[6]: 32
[7]: 63
[8]: 63
[9]: 63
[10]: 63
[11]: 63
[12]: 63
[13]: 63
[14]: 63
[15]: 63
[16]: 63
[17]: 63
[18]: 63
[19]: 32
[20]: 34
[21]: 117
[22]: 115
[23]: 101
[24]: 114
[25]: 34
[26]: 32
[27]: 63
[28]: 63
[29]: 32
[30]: 63
[31]: 63
[32]: 63
[33]: 63
[34]: 63
[35]: 63
[36]: 32
[37]: 63
[38]: 63
[39]: 63
[40]: 63
[41]: 63
[42]: 63
[43]: 63
[44]: 63
[45]: 32
[46]: 63
[47]: 63
[48]: 63
[49]: 63
[50]: 63
[51]: 63
[52]: 63
[53]: 63
[54]: 63
[55]: 63
[56]: 63
[57]: 32
[58]: 40
[59]: 63
[60]: 63
[61]: 32
[62]: 63
[63]: 63
[64]: 63
[65]: 63
[66]: 63
[67]: 63
[68]: 41
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 22 (8 by maintainers)
Can you please try setting lc_messages to ‘Russian_Russia.UTF8’ (not win1251) and setting client_encoding to UTF8?
The normal encoding for communication between Npgsql and PostgreSQL is UTF8, rather than the older codepages such as 1251. You can tell PostgreSQL which encoding to use by setting
client_encoding.@lobster2012-user есть несколько причин таких костылей
Это невозможно, тк npgsql отправляет “SET client_encoding = UTF8” только после успешного подключения. Отсюда у нас и проблемы.
Pg использует доступные системные локали, но вот windows не имеет такой russian_Russian.UTF-8 . Исторически сложилось что для русскоязыных пользователей russian_Russian.WIN1251