341N/A * Copyright The Open Group 341N/A * Permission to use, copy, modify, distribute, and sell this software and its 341N/A * documentation for any purpose is hereby granted without fee, provided that the 341N/A * above copyright notice appear in all copies and that both that copyright notice 341N/A * and this permission notice appear in supporting documentation. 341N/A * The above copyright notice and this permission notice shall be included in all 341N/A * copies or substantial portions of the Software. 341N/A * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 341N/A * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 341N/A * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE OPEN GROUP 341N/A * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF 341N/A * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 341N/A * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 341N/A * Except as contained in this notice, the name of The Open Group shall not be used 341N/A * in advertising or otherwise to promote the sale, use or other dealings in this 341N/A * Software without prior written authorization from The Open Group. 341N/A * Portions also covered by other licenses as noted in the above URL. 341N/A * GB18030, as implemented in glibc-2.2, is an extension of GBK (= CP936). 341N/A * It adds the following ranges: 341N/A * 0xA2E3, 0xA8BF, 0xA98A..0xA995, 0xFE50..0xFE9F 341N/A * 0x{81..84}{30..39}{81..FE}{30..39} 341N/A * Most of Unicode plane 1 in Unicode order. 341N/A * Start: 0x81308130 = 0x0080 341N/A * End: 0x8431A439 = 0xFFFF 341N/A * 0x{90..E3}{30..39}{81..FE}{30..39} 341N/A * Unicode plane 2..16 in Unicode order. 341N/A * Start: 0x90308130 = 0x010000 341N/A * End: 0xE3329A35 = 0x10FFFF 341N/A int v = (s[0] <<
8 | s[
1]);
341N/A /* Code set 2 (remainder of Unicode U+0000..U+FFFF) */ 341N/A /* Code set 0 (ASCII) */ 341N/A /* Code set 1 (GBK extended) */ 341N/A /* Code set 2 (remainder of Unicode U+0000..U+FFFF) */ 341N/A /* Code set 3 (Unicode U+10000..U+10FFFF) */ 341N/A unsigned int i = (((
c1 -
0x90) *
10 + (
c2 -
0x30)) *
126 + (
c3 -
0x81)) *
10 + (
c4 -
0x30);
341N/A if (i >= 0 && i <
0x100000) {
341N/A /* Code set 0 (ASCII) */ 341N/A /* Code set 1 (GBK extended) */ 341N/A /* Code set 2 (remainder of Unicode U+0000..U+FFFF) */ 341N/A int v =
12600 * (r[0] -
0x81) +
1260 * (r[
1] -
0x30) +
10 * (r[
2] -
0x81) + (r[
3] -
0x30);
341N/A r[0] = (v &
0xff00) >>
8;
341N/A /* Code set 3 (Unicode U+10000..U+10FFFF) */ 341N/A r[
3] = (i %
10) +
0x30; i = i /
10;
341N/A r[
2] = (i %
126) +
0x81; i = i /
126;
341N/A r[
1] = (i %
10) +
0x30; i = i /
10;