|
Packit Service |
4684c1 |
/* Decomposition of Unicode characters.
|
|
Packit Service |
4684c1 |
Copyright (C) 2001-2003, 2009-2020 Free Software Foundation, Inc.
|
|
Packit Service |
4684c1 |
Written by Bruno Haible <bruno@clisp.org>, 2009.
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
This program is free software: you can redistribute it and/or
|
|
Packit Service |
4684c1 |
modify it under the terms of either:
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
* the GNU Lesser General Public License as published by the Free
|
|
Packit Service |
4684c1 |
Software Foundation; either version 3 of the License, or (at your
|
|
Packit Service |
4684c1 |
option) any later version.
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
or
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
* the GNU General Public License as published by the Free
|
|
Packit Service |
4684c1 |
Software Foundation; either version 2 of the License, or (at your
|
|
Packit Service |
4684c1 |
option) any later version.
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
or both in parallel, as here.
|
|
Packit Service |
4684c1 |
This program is distributed in the hope that it will be useful,
|
|
Packit Service |
4684c1 |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit Service |
4684c1 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit Service |
4684c1 |
Lesser General Public License for more details.
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
You should have received a copy of the GNU Lesser General Public License
|
|
Packit Service |
4684c1 |
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
#include "unitypes.h"
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
/* The decomposition table is made of two parts:
|
|
Packit Service |
4684c1 |
- A table containing the actual arrays of decomposed equivalents.
|
|
Packit Service |
4684c1 |
(This table is separate because the maximum length of a decomposition
|
|
Packit Service |
4684c1 |
is 18, much larger than the average length 1.497 of a decomposition).
|
|
Packit Service |
4684c1 |
- A 3-level table of indices into this array. */
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
#include "decomposition-table1.h"
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
static inline unsigned short
|
|
Packit Service |
4684c1 |
decomp_index (ucs4_t uc)
|
|
Packit Service |
4684c1 |
{
|
|
Packit Service |
4684c1 |
unsigned int index1 = uc >> decomp_header_0;
|
|
Packit Service |
4684c1 |
if (index1 < decomp_header_1)
|
|
Packit Service |
4684c1 |
{
|
|
Packit Service |
4684c1 |
int lookup1 = gl_uninorm_decomp_index_table.level1[index1];
|
|
Packit Service |
4684c1 |
if (lookup1 >= 0)
|
|
Packit Service |
4684c1 |
{
|
|
Packit Service |
4684c1 |
unsigned int index2 = (uc >> decomp_header_2) & decomp_header_3;
|
|
Packit Service |
4684c1 |
int lookup2 = gl_uninorm_decomp_index_table.level2[lookup1 + index2];
|
|
Packit Service |
4684c1 |
if (lookup2 >= 0)
|
|
Packit Service |
4684c1 |
{
|
|
Packit Service |
4684c1 |
unsigned int index3 = uc & decomp_header_4;
|
|
Packit Service |
4684c1 |
return gl_uninorm_decomp_index_table.level3[lookup2 + index3];
|
|
Packit Service |
4684c1 |
}
|
|
Packit Service |
4684c1 |
}
|
|
Packit Service |
4684c1 |
}
|
|
Packit Service |
4684c1 |
return (unsigned short)(-1);
|
|
Packit Service |
4684c1 |
}
|