-
Notifications
You must be signed in to change notification settings - Fork 2
/
utf16.functions
28 lines (22 loc) · 1.22 KB
/
utf16.functions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# This file is part of shellfire unicode. It is subject to the licence terms in the COPYRIGHT file found in the top-level directory of this distribution and at https://raw.githubusercontent.com/shellfire-dev/unicode/master/COPYRIGHT. No part of shellfire unicode, including this file, may be copied, modified, propagated, or distributed except according to the terms contained in the COPYRIGHT file.
# Copyright © 2014-2015 The developers of shellfire unicode. See the COPYRIGHT file in the top-level directory of this distribution and at https://raw.githubusercontent.com/shellfire-dev/unicode/master/COPYRIGHT.
core_usesIn unicode
unicode_utf16_encodeCodePoint()
{
local endianess="$1"
local codePoint=$(($2+0))
if [ $codePoint -lt 65536 ]; then
_unicode_writeUnsignedShort${endianess} $codePoint
elif [ $codePoint -le 1114111 ]; then
_unicode_writeUnsignedShort${endianess} $(((code_point >> 10) + 55232))
_unicode_writeUnsignedShort${endianess} $(((code_point & 1023) + 56320))
else
core_exitError $core_commandLine_exitCode_SOFTWARE "Invalid code point"
fi
}
unicode_utf16_surrogatePairToCodePoint()
{
local high=$(($1+0))
local low=$(($2+0))
printf '%s' $(((high - 55296) * 1024 + (low - 56320) + 65536))
}