apr_xlate.inc 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. { Copyright 2000-2005 The Apache Software Foundation or its licensors, as
  2. * applicable.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. }
  16. {#include "apu.h"
  17. #include "apr_pools.h"
  18. #include "apr_errno.h"}
  19. {
  20. * @file apr_xlate.h
  21. * @brief APR I18N translation library
  22. }
  23. {
  24. * @defgroup APR_XLATE I18N translation library
  25. * @ingroup APR
  26. }
  27. { Opaque translation buffer }
  28. type
  29. Papr_xlate_t = Pointer;
  30. PPapr_xlate_t = ^Papr_xlate_t;
  31. {
  32. * Set up for converting text from one charset to another.
  33. * @param convset The handle to be filled in by this function
  34. * @param topage The name of the target charset
  35. * @param frompage The name of the source charset
  36. * @param pool The pool to use
  37. * @remark
  38. * Specify APR_DEFAULT_CHARSET for one of the charset
  39. * names to indicate the charset of the source code at
  40. * compile time. This is useful if there are literal
  41. * strings in the source code which must be translated
  42. * according to the charset of the source code.
  43. * APR_DEFAULT_CHARSET is not useful if the source code
  44. * of the caller was not encoded in the same charset as
  45. * APR at compile time.
  46. *
  47. * @remark
  48. * Specify APR_LOCALE_CHARSET for one of the charset
  49. * names to indicate the charset of the current locale.
  50. *
  51. * @remark
  52. * Return APR_EINVAL if unable to procure a convset, or APR_ENOTIMPL
  53. * if charset transcoding is not available in this instance of
  54. * apr-util at all (i.e., APR_HAS_XLATE is undefined).
  55. }
  56. function apr_xlate_open(convset: PPapr_xlate_t;
  57. const topage, frompage: PChar; pool: Papr_pool_t): apr_status_t;
  58. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
  59. external LibAPRUtil name LibNamePrefix + 'apr_xlate_open' + LibSuff16;
  60. {
  61. * This is to indicate the charset of the sourcecode at compile time
  62. * names to indicate the charset of the source code at
  63. * compile time. This is useful if there are literal
  64. * strings in the source code which must be translated
  65. * according to the charset of the source code.
  66. }
  67. //#define APR_DEFAULT_CHARSET (const char *)0
  68. {
  69. * To indicate charset names of the current locale
  70. }
  71. //#define APR_LOCALE_CHARSET (const char *)1
  72. {
  73. * Find out whether or not the specified conversion is single-byte-only.
  74. * @param convset The handle allocated by apr_xlate_open, specifying the
  75. * parameters of conversion
  76. * @param onoff Output: whether or not the conversion is single-byte-only
  77. * @remark
  78. * Return APR_ENOTIMPL if charset transcoding is not available
  79. * in this instance of apr-util (i.e., APR_HAS_XLATE is undefined).
  80. }
  81. function apr_xlate_sb_get(convset: Papr_xlate_t; onoff: PInteger): apr_status_t;
  82. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
  83. external LibAPRUtil name LibNamePrefix + 'apr_xlate_sb_get' + LibSuff8;
  84. { @deprecated @see apr_xlate_sb_get }
  85. function apr_xlate_get_sb(convset: Papr_xlate_t; onoff: PInteger): apr_status_t;
  86. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
  87. external LibAPRUtil name LibNamePrefix + 'apr_xlate_get_sb' + LibSuff8;
  88. {
  89. * Convert a buffer of text from one codepage to another.
  90. * @param convset The handle allocated by apr_xlate_open, specifying
  91. * the parameters of conversion
  92. * @param inbuf The address of the source buffer
  93. * @param inbytes_left Input: the amount of input data to be translated
  94. * Output: the amount of input data not yet translated
  95. * @param outbuf The address of the destination buffer
  96. * @param outbytes_left Input: the size of the output buffer
  97. * Output: the amount of the output buffer not yet used
  98. * @remark
  99. * Return APR_ENOTIMPL if charset transcoding is not available
  100. * in this instance of apr-util (i.e., APR_HAS_XLATE is undefined).
  101. }
  102. function apr_xlate_conv_buffer(convset: Papr_xlate_t; const inbuf: PChar;
  103. inbytes_left: Papr_size_t; outbuf: PChar; outbytes_left: Papr_size_t): apr_status_t;
  104. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
  105. external LibAPRUtil name LibNamePrefix + 'apr_xlate_conv_buffer' + LibSuff20;
  106. { @see apr_file_io.h the comment in apr_file_io.h about this hack }
  107. {$ifdef APR_NOT_DONE_YET}
  108. {
  109. * The purpose of apr_xlate_conv_char is to translate one character
  110. * at a time. This needs to be written carefully so that it works
  111. * with double-byte character sets.
  112. * @param convset The handle allocated by apr_xlate_open, specifying the
  113. * parameters of conversion
  114. * @param inchar The character to convert
  115. * @param outchar The converted character
  116. }
  117. APU_DECLARE(apr_status_t) apr_xlate_conv_char(apr_xlate_t *convset,
  118. char inchar, char outchar);
  119. {$endif}
  120. {
  121. * Convert a single-byte character from one charset to another.
  122. * @param convset The handle allocated by apr_xlate_open, specifying the
  123. * parameters of conversion
  124. * @param inchar The single-byte character to convert.
  125. * @warning This only works when converting between single-byte character sets.
  126. * -1 will be returned if the conversion can't be performed.
  127. }
  128. function apr_xlate_conv_byte(convset: Papr_xlate_t; inchar: Char): apr_int32_t;
  129. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
  130. external LibAPRUtil name LibNamePrefix + 'apr_xlate_conv_byte' + LibSuff8;
  131. {
  132. * Close a codepage translation handle.
  133. * @param convset The codepage translation handle to close
  134. * @remark
  135. * Return APR_ENOTIMPL if charset transcoding is not available
  136. * in this instance of apr-util (i.e., APR_HAS_XLATE is undefined).
  137. }
  138. function apr_xlate_close(convset: Papr_xlate_t): apr_status_t;
  139. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
  140. external LibAPRUtil name LibNamePrefix + 'apr_xlate_close' + LibSuff4;