pg_ls_dir and files with local characters

From: Magnus Johansson <magnus(dot)johansson(at)digpro(dot)se>
To: "pgsql-sql(at)lists(dot)postgresql(dot)org" <pgsql-sql(at)lists(dot)postgresql(dot)org>
Subject: pg_ls_dir and files with local characters
Date: 2026-04-10 12:05:49
Message-ID: MRWPR01MB125758330358214208035A031AF592@MRWPR01MB12575.eurprd01.prod.exchangelabs.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Hello, I have a question regarding pg_ls_dir
I have a directory structure on my windows server (2025) where I run postgres 18

Some of the files listed has Swedish characters in the name.
Like this: Stocksnäsvägen-36-Stocksnäsvägen-36-Noah.pdf

When I run pg_ls_dir on that directory it is listed as this

SELECT * FROM pg_ls_dir('E:\Digpro\Bilder\Dokument\200891');
pg_ls_dir
----------------------------------------------
Stocksnasvagen-36-Stocksnasvagen-36-Noah.pdf
(1 rad)

My Swedish characters are changed to a, sometimes they disapear...

Done some research and I verified that the server and client encoding are the same

dps=# show server_encoding;
server_encoding
-----------------
UTF8

dps=# show client_encoding;
client_encoding
-----------------
UTF8

I have set codepage to utf8 in cmd prompt , chcp 65001

Suspect that this is Windows related, but cannot figure out what to change
Region settings has Swedish (Sweden) as preferred language and only language

I also have a ubuntu server with PG18, if I run the same example there the Swedish characters
Are presented properly. Encoding in PG is UTF8

Appreciate any comments on this.

Best Regards
--
Magnus Johansson

Browse pgsql-sql by date

  From Date Subject
Previous Message Nathan Bossart 2026-03-19 16:44:30 Re: Revoke Connect Privilege from Database not working