blob: 1a835b1c748819c8b105bd25e45d4c9c22a36b27 [file] [log] [blame]
Guido van Rossum5bfc2eb2000-03-10 23:08:04 +00001/* ------------------------------------------------------------------------
2
3 unicodedatabase -- The Unicode 3.0 data base.
4
5 Data was extracted from the Unicode 3.0 UnicodeData.txt file.
6
Fredrik Lundhcfcea492000-09-25 08:07:06 +00007 Written by Marc-Andre Lemburg (mal@lemburg.com).
8 Rewritten for Python 2.0 by Fredrik Lundh (fredrik@pythonware.com)
Guido van Rossum5bfc2eb2000-03-10 23:08:04 +00009
Fredrik Lundhcfcea492000-09-25 08:07:06 +000010 Copyright (c) Corporation for National Research Initiatives.
Guido van Rossum5bfc2eb2000-03-10 23:08:04 +000011
12 ------------------------------------------------------------------------ */
13
Marc-André Lemburgff50ad52000-09-30 17:34:31 +000014#include "Python.h"
Guido van Rossum5bfc2eb2000-03-10 23:08:04 +000015#include "unicodedatabase.h"
16
Fredrik Lundheedb5762000-09-24 21:28:28 +000017/* read the actual data from a separate file! */
18#include "unicodedata_db.h"
Guido van Rossum5bfc2eb2000-03-10 23:08:04 +000019
Fredrik Lundheedb5762000-09-24 21:28:28 +000020const _PyUnicode_DatabaseRecord *
21_PyUnicode_Database_GetRecord(int code)
22{
23 int index;
Guido van Rossum5bfc2eb2000-03-10 23:08:04 +000024
Fredrik Lundheedb5762000-09-24 21:28:28 +000025 if (code < 0 || code >= 65536)
26 index = 0;
27 else {
28 index = index1[(code>>SHIFT)];
29 index = index2[(index<<SHIFT)+(code&((1<<SHIFT)-1))];
30 }
31 return &_PyUnicode_Database_Records[index];
32}
Fredrik Lundhcfcea492000-09-25 08:07:06 +000033
34const char *
35_PyUnicode_Database_GetDecomposition(int code)
36{
37 int index;
38
39 if (code < 0 || code >= 65536)
40 index = 0;
41 else {
42 index = decomp_index1[(code>>DECOMP_SHIFT)];
43 index = decomp_index2[(index<<DECOMP_SHIFT)+
44 (code&((1<<DECOMP_SHIFT)-1))];
45 }
46 return decomp_data[index];
47}