2 # Copyright (c) 2001-2009, PostgreSQL Global Development Group
4 # $PostgreSQL: pgsql/src/backend/utils/mb/Unicode/ucs2utf.pl,v 1.5 2009/01/01 17:23:51 momjian Exp $
5 # convert UCS-4 to UTF-8
13 } elsif ($ucs > 0x007f && $ucs <= 0x07ff) {
14 $utf = (($ucs & 0x003f) | 0x80) | ((($ucs >> 6) | 0xc0) << 8);
15 } elsif ($ucs > 0x07ff && $ucs <= 0xffff) {
16 $utf = ((($ucs >> 12) | 0xe0) << 16) |
17 (((($ucs & 0x0fc0) >> 6) | 0x80) << 8) |
18 (($ucs & 0x003f) | 0x80);
20 $utf = ((($ucs >> 18) | 0xf0) << 24) |
21 (((($ucs & 0x3ffff) >> 12) | 0x80) << 16) |
22 (((($ucs & 0x0fc0) >> 6) | 0x80) << 8) |
23 (($ucs & 0x003f) | 0x80);