Re: Encoding issues in console and eventlog on win32

From: Itagaki Takahiro <itagaki(dot)takahiro(at)oss(dot)ntt(dot)co(dot)jp>
To: Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Encoding issues in console and eventlog on win32
Date: 2009-09-15 03:49:49
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com> wrote:

> Can't we use MultiByteToWideChar() to convert directly to the required
> encoding, avoiding the double conversion?

Here is an updated version of the patch.
I use direct conversion in pgwin32_toUTF16() if a corresponding codepage
is available. If not available, I still use double conversion.

Now pgwin32_toUTF16() is exported from mbutil.c. I used the function
in following parts, although the main target of the patch is eventlog.

* WriteConsoleW() - write unredirected stderr log.
* ReportEventW() - write evenlog.
* CreateFileW() - open non-ascii filename (ex. COPY TO/FROM 'mb-path').

This approach is only available for Windows because any other platform
don't support locale-independent and wide-character-based system calls.
Other platforms require a different approach, but even then we'd still
better have win32-specific routines because UTF16 is the native encoding
in Windows.

ITAGAKI Takahiro
NTT Open Source Software Center

Attachment Content-Type Size
eventlog-20090915.patch application/octet-stream 14.7 KB

In response to


Browse pgsql-hackers by date

  From Date Subject
Next Message Andrew Gierth 2009-09-15 04:13:21 Re: [BUGS] BUG #5053: domain constraints still leak
Previous Message Tom Lane 2009-09-15 03:20:59 Re: [BUGS] BUG #5053: domain constraints still leak