Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

140 lines
6.3 KiB

  1. #ifndef __GB18030_H
  2. #define __GB18030_H
  3. //
  4. // Flags for dwFlags in NlsDllCodePageTranslation.
  5. //
  6. #define NLS_CP_CPINFO 0x10000000
  7. #define NLS_CP_MBTOWC 0x40000000
  8. #define NLS_CP_WCTOMB 0x80000000
  9. ////////////////////////////////////////////////////////////////////////////
  10. //
  11. // gb18030.h
  12. //
  13. // This is the header for using the c_g18030.dll in the system.
  14. // This file lists all exported functions in c_g18030.dll.
  15. // c_g18030.dll is a codpeage conversion DLL for the Chinese GB-18030 codepage
  16. // (Windows codepage 54936).
  17. //
  18. // The best way to use c_g18030.dll is to use the Windows API
  19. // MultiByteToWideChar() and WideCharToMultiByte(), and pass 54936 as the codepage
  20. // number. Internally, MultiByteToWideChar() and WideCharToMultiByte() call function
  21. // in c_g18030.dll using these exported functions.
  22. //
  23. // You can also use this header and load these functions dynamically from c_g18030.dll.
  24. // However, this is not recommended since MulitByteToWideChar() and WideCharToMultiByte()
  25. // are much easier to use.
  26. //
  27. ////////////////////////////////////////////////////////////////////////////
  28. ////////////////////////////////////////////////////////////////////////////
  29. //
  30. // NlsDllCodePageTranslation
  31. // This routine is the main exported procedure for the functionality in
  32. // c_g18030.dll. It can be used to get code page information or do conversion
  33. // depending on the value of dwFlags.
  34. //
  35. // Parameters:
  36. // CodePage The value of the codepage. The value should be 54936. Otherwise,
  37. // 0 will be returned and GetLastError() will return ERROR_INVALID_PARAMETER.
  38. //
  39. // dwFlags It can be one of these values
  40. // NLS_CP_CPINFO To return code page information in the buffer pointed by
  41. // lpCPInfo. lpMultiByteStr/cchMultiByte/lpWideCharStr/cchWideChar are not used.
  42. //
  43. // NLS_CP_MBTOWC Convert GB-18030 bytes to Unicode characters.
  44. // The source GB-18030 characters should be pointed by lpMultiByteStr, and cchMultiByte should
  45. // contains the byte count of the buffer.
  46. // The Unicode result will be stored in the buffer pointed by lpWideCharStr, and cchWideChar
  47. // should contain the character count of the Unicode buffer.
  48. // If lpWideCharStr or cchWideChar are zero, the expected character count of the Unicode result
  49. // will be returned, and no real conversion will be done.
  50. // lpCPInfo is not used in this case.
  51. //
  52. // NLS_CP_WCTOMB Convert Unicode characters to GB-18030 bytes.
  53. // The source Unicode string should be pointed by lpWideCharStr, and cchWideChar should
  54. // contians the character count of the buffer.
  55. // The GB-18030 result will be stored in the buffer pointed by lpMultiByteStr, and cchMultiByte
  56. // should contain the byte count of the GB-18030 buffer.
  57. // If lpMultiByteStr or cchMultiByte are zero, the byte count of the GB-18030 result
  58. // will be returned, and no real conversion will be done.
  59. // lpCPInfo is not used in this case.
  60. //
  61. // lpMulitByteStr Pointed to a buffer which contains multi-byte GB-18030 characters. This can be a source buffer
  62. // or target buffer, depending on the value of dwFlags.
  63. //
  64. // cchMulitByte The byte count of the multi-byte buffer.
  65. //
  66. // lpWideCharStr Pointed to a buffer which contains Unicode characters. This can be a source buffer
  67. // or target buffer, depending on the value of dwFlags.
  68. //
  69. // cchWideChar The character count of the Unicode buffer.
  70. //
  71. // lpCPInfo A pointer which points to a structure of CPINFO. CPINFO is defined in Platform SDK.
  72. //
  73. // Returns:
  74. // 1 if the function succeeds.
  75. // 0 if the function fails
  76. //
  77. ////////////////////////////////////////////////////////////////////////////
  78. STDAPI_(DWORD) NlsDllCodePageTranslation(
  79. DWORD CodePage,
  80. DWORD dwFlags,
  81. LPSTR lpMultiByteStr,
  82. int cchMultiByte,
  83. LPWSTR lpWideCharStr,
  84. int cchWideChar,
  85. LPCPINFO lpCPInfo);
  86. ////////////////////////////////////////////////////////////////////////////
  87. //
  88. // BytesToUnicode
  89. //
  90. // Convert GB-18030 bytes to Unicode characters.
  91. //
  92. // Parameters:
  93. // [IN] lpMultiByteStr The multi-byte string to be converted.
  94. // [IN] cchMultiByte The byte count of the multi-byte string to be converted
  95. // [OUT] pcchLeftOverBytes Pointer to UINT which contains GB-18030 bytes at the end of the buffer that can not be converted.
  96. // These bytes could be the leading bytes of valid GB18030 bytes in the next incoming GB18030 bytes.
  97. // [IN] lpWiedCharStr The target Unicode buffer.
  98. // [IN] cchWideChar The character count of the target Unicode buffer.
  99. //
  100. // Returns:
  101. // The character count of the Unicode character that are converted.
  102. //
  103. ////////////////////////////////////////////////////////////////////////////
  104. STDAPI_(DWORD) BytesToUnicode(
  105. BYTE* lpMultiByteStr,
  106. UINT cchMultiByte,
  107. UINT* pcchLeftOverBytes,
  108. LPWSTR lpWideCharStr,
  109. UINT cchWideChar);
  110. ////////////////////////////////////////////////////////////////////////////
  111. //
  112. // UnicodeToBytes
  113. //
  114. // Convert Unicode characters to GB-18030 bytes.
  115. //
  116. // Parameters:
  117. // [IN] lpWideCharStr The Unicode string to be converted.
  118. // [IN] cchWideChar The character count of the Unicode string to be converted.
  119. // [IN] lpMultiByteStr The target multi-byte buffer.
  120. // [IN] cchMultiByte The byte count of the target multi-byte buffer.
  121. //
  122. // Returns:
  123. // The byte count of the Unicode character that are generated.
  124. //
  125. ////////////////////////////////////////////////////////////////////////////
  126. STDAPI_(DWORD) UnicodeToBytes(
  127. LPWSTR lpWideCharStr,
  128. UINT cchWideChar,
  129. LPSTR lpMultiByteStr,
  130. UINT cchMultiByte);
  131. #endif