unicode.h 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /*
  2. * Wine internal Unicode definitions
  3. *
  4. * Copyright 2000 Alexandre Julliard
  5. *
  6. * This library is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU Lesser General Public
  8. * License as published by the Free Software Foundation; either
  9. * version 2.1 of the License, or (at your option) any later version.
  10. *
  11. * This library is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public
  17. * License along with this library; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
  19. */
  20. #ifndef __WINE_UNICODE_H
  21. #define __WINE_UNICODE_H
  22. #include <stdarg.h>
  23. #include <windef.h>
  24. #include <winbase.h>
  25. #include <winnls.h>
  26. /* code page info common to SBCS and DBCS */
  27. struct cp_info
  28. {
  29. unsigned int codepage; /* codepage id */
  30. unsigned int char_size; /* char size (1 or 2 bytes) */
  31. WCHAR def_char; /* default char value (can be double-byte) */
  32. WCHAR def_unicode_char; /* default Unicode char value */
  33. const char *name; /* code page name */
  34. };
  35. struct sbcs_table
  36. {
  37. struct cp_info info;
  38. const WCHAR *cp2uni; /* code page -> Unicode map */
  39. const WCHAR *cp2uni_glyphs; /* code page -> Unicode map with glyph chars */
  40. const unsigned char *uni2cp_low; /* Unicode -> code page map */
  41. const unsigned short *uni2cp_high;
  42. };
  43. struct dbcs_table
  44. {
  45. struct cp_info info;
  46. const WCHAR *cp2uni; /* code page -> Unicode map */
  47. const unsigned char *cp2uni_leadbytes;
  48. const unsigned short *uni2cp_low; /* Unicode -> code page map */
  49. const unsigned short *uni2cp_high;
  50. unsigned char lead_bytes[12]; /* lead bytes ranges */
  51. };
  52. union cptable
  53. {
  54. struct cp_info info;
  55. struct sbcs_table sbcs;
  56. struct dbcs_table dbcs;
  57. };
  58. static inline unsigned int strlenW( const WCHAR *str )
  59. {
  60. const WCHAR *s = str;
  61. while (*s) s++;
  62. return s - str;
  63. }
  64. static inline unsigned short get_char_typeW( WCHAR ch )
  65. {
  66. extern const unsigned short wine_wctype_table[];
  67. return wine_wctype_table[wine_wctype_table[ch >> 8] + (ch & 0xff)];
  68. }
  69. static inline WCHAR tolowerW( WCHAR ch )
  70. {
  71. extern const WCHAR wine_casemap_lower[];
  72. return ch + wine_casemap_lower[wine_casemap_lower[ch >> 8] + (ch & 0xff)];
  73. }
  74. #endif /* __WINE_UNICODE_H */