Re: Encoding issues in console and eventlog on win32 - Mailing list pgsql-hackers

From Itagaki Takahiro
Subject Re: Encoding issues in console and eventlog on win32
Date
Msg-id 20090915123243.9C59.52131E4D@oss.ntt.co.jp
Whole thread Raw
In response to Re: Encoding issues in console and eventlog on win32  (Heikki Linnakangas <heikki.linnakangas@enterprisedb.com>)
Responses Re: Encoding issues in console and eventlog on win32
Re: Encoding issues in console and eventlog on win32
List pgsql-hackers
Heikki Linnakangas <heikki.linnakangas@enterprisedb.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.

Regards,
---
ITAGAKI Takahiro
NTT Open Source Software Center


Attachment

pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: [BUGS] BUG #5053: domain constraints still leak
Next
From: Andrew Gierth
Date:
Subject: Re: [BUGS] BUG #5053: domain constraints still leak