1

I'm using PostgreSQL v15 on win11, but accented character are broken in my DB.

What I've tried so far :

I switched to the "Bêta UTF8" thanks to this post: https://techcommunity.microsoft.com/t5/windows-powershell/how-to-change-default-code-page-of-powershell-console/m-p/2275773
that point to this stack overflow answer:
Using UTF-8 Encoding (CHCP 65001) in Command Prompt / Windows Powershell (Windows 10)

But ! know that my accented chars are repaired I can't do SQL request : INSERT INTO with some values that contains accented chars!

So I searched.. in the abysses of the web... losts forums, psql documentation, and I found some things about the psql client_encoding, after some times of playing with it, it seems to work perfectly only if I set :

  • a new environment variable PGCLIENTENCODING to WIN1252
  • and type, everytime I open a new cmd or powershell terminal : chcp 1252

edit : It's the bad way to solve this, I have to stick in UTF8. I'll try something else If someone have some hints.

Ken White
  • 123,280
  • 14
  • 225
  • 444
Yannize
  • 11
  • 3
  • 1
    no, that's not a good way. You need to convert your sql db to UTF-8. Using everything in UTF-8 would save a lot of headache later – phuclv Nov 15 '22 at 01:39
  • @phuclv I tried everything from the links I shared, everything In utf8 (chcp 65001, bdd in utf8, and "bêta utf8" in win11 regional settings) doesn't work, I could see accented chars with a SELECT query, but can't INSERT accented chars. That's why I'm searching for something else – Yannize Nov 15 '22 at 09:49
  • that's an [XY problem](https://meta.stackexchange.com/q/66377/230282). Instead of showing what you've tried and asking what was wrong with that and how to do it correctly, you've assumed that changing the code page is the way to solve it. I can assure you that using anything not Unicode nowadays would be a bad idea and fixing it in the future would be painful – phuclv Nov 15 '22 at 15:22
  • besides version-specific tags like [tag:powershell-4.0] must only be used for things that only apply/occur to that version. Definitely Windows 11 doesn't come with powershell 4.0 – phuclv Nov 15 '22 at 15:23
  • @phuclv I though in the dev's world, the rule is to tell your problem, and what you've tried to do to resolve it, so other devs can propose something that have not been tried yet. Maybe I'm wrong, If my issue is not clear, I will update this post, but at the beginning I say : "I'm using PostgreSQL v15 on win11, but accented character are broken", that's the main issue. Thanks for the warning, I stop searching to change the chcp and stick with UTF8 everywhere and try to find another way. (Maybe just use WSL, so there will be no more issue). – Yannize Nov 16 '22 at 01:05
  • If 'typing chcp whenever starting cmd' is a problem, you can edit registry: https://superuser.com/a/269857 – Sangbok Lee Apr 06 '23 at 02:10

0 Answers0