mirror of
https://github.com/postgres/postgres.git
synced 2025-11-21 00:42:43 +03:00
Add support for code conversion between Unicode and other encodings.
Supported encodings are: EUC_JP, EUC_CN, EUC_KR, EUC_TW, Shift JIS, Big5, ISO8859-[1-5]. TODO: testings! and documentations...
This commit is contained in:
20
src/backend/utils/mb/Unicode/ucs2utf.pl
Normal file
20
src/backend/utils/mb/Unicode/ucs2utf.pl
Normal file
@@ -0,0 +1,20 @@
|
||||
#
|
||||
# $Id: ucs2utf.pl,v 1.1 2000/10/30 10:40:30 ishii Exp $
|
||||
# convert UCS-2 to UTF-8
|
||||
#
|
||||
sub ucs2utf {
|
||||
local($ucs) = @_;
|
||||
local $utf;
|
||||
|
||||
if ($ucs <= 0x007f) {
|
||||
$utf = $ucs;
|
||||
} elsif ($ucs > 0x007f && $ucs <= 0x07ff) {
|
||||
$utf = (($ucs & 0x003f) | 0x80) | ((($ucs >> 6) | 0xc0) << 8);
|
||||
} else {
|
||||
$utf = ((($ucs >> 12) | 0xe0) << 16) |
|
||||
(((($ucs & 0x0fc0) >> 6) | 0x80) << 8) |
|
||||
(($ucs & 0x003f) | 0x80);
|
||||
}
|
||||
return($utf);
|
||||
}
|
||||
1;
|
||||
Reference in New Issue
Block a user