upper()/lower() truncates the result under Japanese Windows

From: Hiroshi Inoue <inoue(at)tpf(dot)co(dot)jp>
To: pgsql-hackers(at)postgresql(dot)org
Subject: upper()/lower() truncates the result under Japanese Windows
Date: 2008-12-14 10:22:02
Message-ID: 4944DE4A.8050001@tpf.co.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

Upper(), lower() or initcap() function truncates the result
under Japanese Windows with e.g. the server encoding=UTF-8
and the LC_CTYPE setting Japanese_japan.932 .

Below is an example.

$ psql
psql (8.4devel)
Type "help" for help.

inoue=# \encoding sjis

inoue=# show server_encoding;
server_encoding
-----------------
UTF8
(1 行)

inoue=# show LC_CTYPE;
lc_ctype
--------------------
Japanese_Japan.932
(1 行)

inoue=# \set jpnstr '''カタカナ'''
inoue=# select char_length(:jpnstr);
char_length
-------------
4
(1 行)

inoue=# select upper(:jpnstr);
upper
--------
カタカ
(1 行)

inoue=# select char_length(upper(:jpnstr));
char_length
-------------
3
(1 行)

The output of the last command should be 4 not 3.
Attached is a patch to fix the bug.
After applying the patch the result is

inoue=# select upper(:jpnstr);
upper
----------
カタカナ
(1 行)

inoue=# select char_length(upper(:jpnstr));
char_length
-------------
4
(1 行)

regards,
Hiroshi Inoue

Attachment Content-Type Size
formatting.patch text/plain 3.4 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Jan Urbański 2008-12-14 10:58:53 Re: Stats target increase vs compute_tsvector_stats()
Previous Message Emmanuel Cecchet 2008-12-14 09:17:52 Re: Sync Rep: First Thoughts on Code