2 * Copyright (c) 2009 Nicira Networks.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at:
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
21 /* Returns the unicode code point corresponding to leading surrogate 'leading'
22 * and trailing surrogate 'trailing'. The return value will not make any
23 * sense if 'leading' or 'trailing' are not in the correct ranges for leading
24 * or trailing surrogates. */
26 utf16_decode_surrogate_pair(int leading, int trailing)
29 * Leading surrogate: 110110wwwwxxxxxx
30 * Trailing surrogate: 110111xxxxxxxxxx
31 * Code point: 000uuuuuxxxxxxxxxxxxxxxx
33 int w = (leading >> 6) & 0xf;
35 int x0 = leading & 0x3f;
36 int x1 = trailing & 0x3ff;
37 return (u << 16) | (x0 << 10) | x1;