home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 15 / AACD15.ISO / AACD / Programming / Python2 / Python20_source / Modules / unicodedatabase.c < prev    next >
Encoding:
C/C++ Source or Header  |  2000-10-25  |  1.2 KB  |  48 lines

  1. /* ------------------------------------------------------------------------
  2.  
  3.    unicodedatabase -- The Unicode 3.0 data base.
  4.  
  5.    Data was extracted from the Unicode 3.0 UnicodeData.txt file.
  6.  
  7.    Written by Marc-Andre Lemburg (mal@lemburg.com).
  8.    Rewritten for Python 2.0 by Fredrik Lundh (fredrik@pythonware.com)
  9.  
  10.    Copyright (c) Corporation for National Research Initiatives.
  11.  
  12.    ------------------------------------------------------------------------ */
  13.  
  14. #include "Python.h"
  15. #include "unicodedatabase.h"
  16.  
  17. /* read the actual data from a separate file! */
  18. #include "unicodedata_db.h"
  19.  
  20. const _PyUnicode_DatabaseRecord *
  21. _PyUnicode_Database_GetRecord(int code)
  22. {
  23.     int index;
  24.  
  25.     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. }
  33.  
  34. const 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. }
  48.