Bug with PATHs having non-ASCII characters

Chuck McDevitt <cmcdevitt@greenplum.com>

From: Chuck McDevitt <cmcdevitt@greenplum.com>
To: "pgsql-hackers@postgresql.org" <pgsql-hackers@postgresql.org>
Date: 2010-01-07T00:57:23Z
Lists: pgsql-hackers
Just an FYI regarding this bug:

http://archives.postgresql.org/pgsql-bugs/2009-12/msg00267.php

Windows always uses UNICODE to store file and directory names.

The wide-char version of any WIN32 API call will accept or return data in UTF-16 encoded Unicode, regardless of the local environment's single-byte (MBCS) encoding settings (codepage).

So in the windows environment, at least, you can always be sure how to handle file/directory/path that includes non-ASCII characters.

It's a little bit of a pain to use the wide-char API calls from PostgreSQL, but converting UTF-16 from and to UTF-8 is pretty easy and a guaranteed 1:1 mapping.

P.s. The non-wide-char version of the Win32 API is just a bunch of wrappers that convert the char data to/from UTF-16 based on the current codepage.  The wide-char API is the native one.
To force the call to the wide-char API version, you just add W to the end of the function name (adding A forces it the other way).