pg_ls_dir and files with local characters

Magnus Johansson <magnus.johansson@digpro.se>

From: Magnus Johansson <magnus.johansson@digpro.se>
To: "pgsql-sql@lists.postgresql.org" <pgsql-sql@lists.postgresql.org>
Date: 2026-04-10T12:05:49Z
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