winduni.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. /* winduni.h -- header file for unicode support for windres program.
  2. Copyright (C) 1997-2022 Free Software Foundation, Inc.
  3. Written by Ian Lance Taylor, Cygnus Support.
  4. Rewritten by Kai Tietz, Onevision.
  5. This file is part of GNU Binutils.
  6. This program is free software; you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation; either version 3 of the License, or
  9. (at your option) any later version.
  10. This program is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. GNU General Public License for more details.
  14. You should have received a copy of the GNU General Public License
  15. along with this program; if not, write to the Free Software
  16. Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
  17. 02110-1301, USA. */
  18. #include "ansidecl.h"
  19. #ifndef WINDUNI_H
  20. #define WINDUNI_H
  21. /* This header file declares the types and functions we use for
  22. unicode support in windres. Our unicode support is very limited at
  23. present.
  24. We don't put this stuff in windres.h so that winduni.c doesn't have
  25. to include windres.h. winduni.c needs to includes windows.h, and
  26. that would conflict with the definitions of Windows macros we
  27. already have in windres.h. */
  28. /* Use bfd_size_type to ensure a sufficient number of bits. */
  29. #ifndef DEFINED_RC_UINT_TYPE
  30. #define DEFINED_RC_UINT_TYPE
  31. typedef bfd_size_type rc_uint_type;
  32. #endif
  33. /* We use this type to hold a unicode character. */
  34. typedef unsigned short unichar;
  35. /* Escape character translations. */
  36. #define ESCAPE_A 007
  37. #define ESCAPE_B 010
  38. #define ESCAPE_F 014
  39. #define ESCAPE_N 012
  40. #define ESCAPE_R 015
  41. #define ESCAPE_T 011
  42. #define ESCAPE_V 013
  43. /* Convert an ASCII string to a unicode string. */
  44. extern void unicode_from_ascii (rc_uint_type *, unichar **, const char *);
  45. /* Convert an unicode string to an ASCII string. */
  46. extern void ascii_from_unicode (rc_uint_type *, const unichar *, char **);
  47. /* Duplicate a unicode string by using res_alloc. */
  48. extern unichar *unichar_dup (const unichar *);
  49. /* Duplicate a unicode string by using res_alloc and make it uppercase. */
  50. extern unichar *unichar_dup_uppercase (const unichar *);
  51. /* The count of unichar elements. */
  52. extern rc_uint_type unichar_len (const unichar *);
  53. /* Print a unicode string to a file. */
  54. extern void unicode_print (FILE *, const unichar *, rc_uint_type);
  55. /* Print a ascii string to a file. */
  56. extern void ascii_print (FILE *, const char *, rc_uint_type);
  57. /* Print a quoted unicode string to a file. */
  58. extern void unicode_print_quoted (FILE *, const unichar *, rc_uint_type);
  59. #ifndef CP_UTF8
  60. #define CP_UTF7 65000 /* UTF-7 translation. */
  61. #define CP_UTF8 65001 /* UTF-8 translation. */
  62. #endif
  63. #ifndef CP_UTF16
  64. #define CP_UTF16 65002 /* UTF-16 translation. */
  65. #endif
  66. #ifndef CP_ACP
  67. #define CP_ACP 0 /* Default to ANSI code page. */
  68. #endif
  69. #ifndef CP_OEM
  70. #define CP_OEM 1 /* Default OEM code page. */
  71. #endif
  72. /* Specifies the default codepage to be used for unicode
  73. transformations. By default this is CP_ACP. */
  74. extern rc_uint_type wind_default_codepage;
  75. /* Specifies the currently used codepage for unicode
  76. transformations. By default this is CP_ACP. */
  77. extern rc_uint_type wind_current_codepage;
  78. typedef struct wind_language_t
  79. {
  80. unsigned id;
  81. unsigned doscp;
  82. unsigned wincp;
  83. const char *name;
  84. const char *country;
  85. } wind_language_t;
  86. extern const wind_language_t *wind_find_language_by_id (unsigned);
  87. extern int unicode_is_valid_codepage (rc_uint_type);
  88. typedef struct local_iconv_map
  89. {
  90. rc_uint_type codepage;
  91. const char * iconv_name;
  92. } local_iconv_map;
  93. extern const local_iconv_map *wind_find_codepage_info (unsigned);
  94. /* Convert an Codepage string to a unicode string. */
  95. extern void unicode_from_codepage (rc_uint_type *, unichar **, const char *, rc_uint_type);
  96. extern void unicode_from_ascii_len (rc_uint_type *, unichar **, const char *, rc_uint_type );
  97. /* Convert an unicode string to an codepage string. */
  98. extern void codepage_from_unicode (rc_uint_type *, const unichar *, char **, rc_uint_type);
  99. /* Windres support routine called by unicode_from_ascii. This is both
  100. here and in windres.h. It should probably be in a separate header
  101. file, but it hardly seems worth it for one function. */
  102. extern void * res_alloc (rc_uint_type);
  103. #endif