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.

117 lines
2.6 KiB

  1. /*++
  2. Copyright (c) 1998 Microsoft Corporation
  3. Module Name:
  4. unicode.h
  5. Abstract:
  6. Declares the interfaces for unicode/ansi conversion.
  7. See macros at the end of this file for details! (Search for ***)
  8. Author:
  9. Jim Schmidt (jimschm) 02-Sep-1997
  10. Revision History:
  11. jimschm 16-Mar-2000 PTSTR<->PCSTR/PCWSTR routines
  12. jimschm 15-Feb-1999 Eliminated AnsiFromUnicode and UnicodeFromAnsi
  13. calinn 07-Jul-1998 SetGlobalPage/GetGlobalPage
  14. mikeco 03-Nov-1997 AnsiFromUnicode/UnicodeFromAnsi
  15. --*/
  16. #pragma once
  17. #ifdef __cplusplus
  18. extern "C" {
  19. #endif
  20. //
  21. // Function Prototoypes
  22. //
  23. //
  24. // Pre-allocated buffer conversion routines.
  25. // End of string is returned.
  26. //
  27. PWSTR
  28. SzConvertBufferBytesAToW (
  29. OUT PWSTR OutputBuffer,
  30. IN PCSTR InputString,
  31. IN UINT ByteCountInclNul
  32. );
  33. #define SzConvertBufferAToW(out,in) SzConvertBufferBytesAToW(out,in,SzSizeA(in))
  34. PSTR
  35. SzConvertBufferBytesWToA (
  36. OUT PSTR OutputBuffer,
  37. IN PCWSTR InputString,
  38. IN UINT ByteCountInclNul
  39. );
  40. #define SzConvertBufferWToA(out,in) SzConvertBufferBytesWToA(out,in,SzSizeW(in))
  41. //
  42. // Duplicate & convert routines
  43. //
  44. // SzConvertAToW(ansi) returns unicode
  45. // SzConvertWToA(unicode) returns ansi
  46. //
  47. PWSTR
  48. RealSzConvertBytesAToW (
  49. IN PCSTR AnsiString,
  50. IN UINT ByteCountInclNul
  51. );
  52. #define SzConvertBytesAToW(ansi,bytes) DBGTRACK(PWSTR, SzConvertBytesAToW, (ansi,bytes))
  53. #define SzConvertAToW(ansi) SzConvertBytesAToW(ansi,SzSizeA(ansi))
  54. PSTR
  55. RealSzConvertBytesWToA (
  56. IN PCWSTR UnicodeString,
  57. IN UINT ByteCountInclNul
  58. );
  59. #define SzConvertBytesWToA(unicode,bytes) DBGTRACK(PSTR, SzConvertBytesWToA, (unicode,bytes))
  60. #define SzConvertWToA(unicode) SzConvertBytesWToA(unicode,SzSizeW(unicode))
  61. //
  62. // Routines to convert to & from TCHAR
  63. //
  64. #ifdef UNICODE
  65. #define SzConvertToTstrA(ansi) SzConvertAToW(ansi)
  66. #define SzConvertToTstrW(unicode) (unicode)
  67. #define SzConvertFromTstrA(tstr) SzConvertWToA(tstr)
  68. #define SzConvertFromTstrW(tstr) (tstr)
  69. #else
  70. #define SzConvertToTstrA(ansi) (ansi)
  71. #define SzConvertToTstrW(unicode) SzConvertWToA(unicode)
  72. #define SzConvertFromTstrA(tstr) (tstr)
  73. #define SzConvertFromTstrW(tstr) SzConvertAToW(tstr)
  74. #endif
  75. #define SzFreeTstrConversion(original,converted) ((converted) && ((PBYTE) (converted) != (PBYTE) (original)) ? FAST_FREE(converted) : 1)
  76. #ifdef __cplusplus
  77. }
  78. #endif