Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1YVSiq-0003RN-M6 for pgsql-bugs@arkaria.postgresql.org; Tue, 10 Mar 2015 22:33:56 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1YVSiq-0003WE-4X for pgsql-bugs@arkaria.postgresql.org; Tue, 10 Mar 2015 22:33:56 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1YVSip-0003Vo-0V for pgsql-bugs@postgresql.org; Tue, 10 Mar 2015 22:33:55 +0000 Received: from mail-la0-x22e.google.com ([2a00:1450:4010:c03::22e]) by makus.postgresql.org with esmtps (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.80) (envelope-from ) id 1YVSik-0008QA-Tp for pgsql-bugs@postgresql.org; Tue, 10 Mar 2015 22:33:53 +0000 Received: by labge10 with SMTP id ge10so4553340lab.10 for ; Tue, 10 Mar 2015 15:33:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:message-id:date:from:reply-to:user-agent:mime-version:to:cc :subject:references:in-reply-to:content-type :content-transfer-encoding; bh=0h7qRCRs4//WSYKnyygohttSfjXYIb5Q98YiRbBGHM0=; b=IJ+j3KMTJ7x2FQKe3BuajpF+Zk0esivhTbzjDQzOs03+wtlgQB1WikI5JFSzcuHd6S 2l5nafX0CN4RyROQfLUlptw6ywHcFQIx4BJerkY+Ev0NxHx6ToyDlh5Q+llD46oLk3lp bqBepW4hx03Oc6VafutGBboq4uoTAzsDfpI5Yrdwc+buAoc09kddvTY/bwImy4lKki7W ++XlUTxkFPaPq4wQVqRSGhwSW+op9EU1VWU6qSDKXbrKEExvjwLd1S+O6V9+Kxl6L+1m MmZzckKJPBtJ/vO94b6TqDzICbA+JRidBRryRVHruZH9uaLjvordRyZcRskfRAJbIn0G Be7w== X-Received: by 10.152.36.226 with SMTP id t2mr30675837laj.53.1426026827395; Tue, 10 Mar 2015 15:33:47 -0700 (PDT) Received: from [10.43.4.179] ([212.98.78.41]) by mx.google.com with ESMTPSA id w9sm365750laj.24.2015.03.10.15.33.44 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 10 Mar 2015 15:33:45 -0700 (PDT) Message-ID: <54FF7147.20204@iki.fi> Date: Tue, 10 Mar 2015 23:33:43 +0100 From: Heikki Linnakangas Reply-To: hlinnaka@iki.fi User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Icedove/31.5.0 MIME-Version: 1.0 To: Arjen Nienhuis CC: pgsql-bugs@postgresql.org Subject: Re: BUG #12845: The GB18030 encoding doesn't support Unicode characters over 0xFFFF References: <20150309205145.4031.32069@wrigleys.postgresql.org> <54FF633B.9090006@iki.fi> In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -2.4 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org On 03/10/2015 11:21 PM, Arjen Nienhuis wrote: > On 10 Mar 2015 22:33, "Heikki Linnakangas" wrote: >> >> On 03/09/2015 10:51 PM, a.g.nienhuis@gmail.com wrote: >>> >>> arjen=> select convert_to(chr(128512), 'GB18030'); >>> >>> Actual output: >>> >>> ERROR: character with byte sequence 0xf0 0x9f 0x98 0x80 in encoding > "UTF8" >>> has no equivalent in encoding "GB18030" >>> >>> Expected output: >>> >>> convert_to >>> ------------ >>> \x9439fc36 >>> (1 row) >> >> >> Hmm, looks like our gb18030 <-> Unicode conversion table only contains > the Unicode BMP plane. Unicode points above 0xffff are not included. >> >> If we added all the missing mappings as one to one mappings, like we've > done for the BMP, that would bloat the table horribly. There are over 1 > million code points that are currently not mapped. Fortunately, the missing > mappings are in linear ranges that would be fairly simple to handle in > programmatically. See e.g. > https://ssl.icu-project.org/repos/icu/data/trunk/charset/source/gb18030/gb18030.html. > Someone needs to write the code (I'm not volunteering myself). > > I can write a "uint32 UTF8toGB18030(uint32)" function, but I don't know > where to put it in the code. The mapping functions are in src/backend/utils/mb/conversion_procs/utf8_and_gb18030/utf8_and_gb18030.c. They currently just consult the mapping table. You'd need to modify them to also check if the codepoint is in one of those linear ranges, and do the mapping for those programmatically. > Else I could also extend the map file. It would double in size if it only > needs to include valid code points. The current mapping table contains about 63000 mappings, but there are over a million valid code points that need to be mapped. If you just add every one-to-one mapping to the table, it's going to blow up in size to over 8 MB. I don't think we want that, handling the ranges with linear mappings programmatically makes a lot more sense. - Heikki -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs