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.

66 lines
2.8 KiB

  1. /******************************Module*Header*******************************\
  2. * Module Name: nlsconv.h
  3. *
  4. * Created: 08-Sep-1991 14:01:23
  5. * Author: Bodin Dresevic [BodinD]
  6. * 02-Feb-1993 00:32:35
  7. * Copyright (c) 1991-1999 Microsoft Corporation.
  8. *
  9. * (General description of its use)
  10. *
  11. \**************************************************************************/
  12. #include "winuserp.h" // nls conversion routines
  13. #include <crt\stdlib.h> // c rtl library include file off of nt\public\sdk\inc
  14. /******************************Public*Macro******************************\
  15. * bToASCIIN(pszDst, cch, pwszSrc, cwch)
  16. *
  17. * Calls the Rtl function that convert multi-byte ANSI to Unicode via
  18. * the current codepage. Note that this macro does not guarantee a
  19. * terminating NULL for the destination.
  20. *
  21. * Returns:
  22. * TRUE if converted successfully, FALSE otherwise.
  23. *
  24. \**************************************************************************/
  25. #define bToASCII_N(pszDst, cch, pwszSrc, cwch) \
  26. ( \
  27. NT_SUCCESS(RtlUnicodeToMultiByteN((PCH)(pszDst), (ULONG)(cch), \
  28. (PULONG)NULL,(PWSZ)(pwszSrc), (ULONG)((cwch)*sizeof(WCHAR)))) \
  29. )
  30. /******************************Public*Macro******************************\
  31. * vToUnicodeN(awchDst, cwchDst, achSrc, cchSrc)
  32. *
  33. * Calls the Rtl function that convert Unicode to multi-byte ANSI via
  34. * the current codepage. Note that this macro does not guarantee a
  35. * terminating NULL for the destination.
  36. *
  37. * Returns:
  38. * Nothing. Should not be able to fail.
  39. *
  40. \**************************************************************************/
  41. #if DBG
  42. #define vToUnicodeN( awchDst, cwchDst, achSrc, cchSrc ) \
  43. { \
  44. NTSTATUS st = \
  45. RtlMultiByteToUnicodeN( \
  46. (PWSZ)(awchDst),(ULONG)((cwchDst)*sizeof(WCHAR)), \
  47. (PULONG)NULL,(PSZ)(achSrc),(ULONG)(cchSrc)); \
  48. \
  49. ASSERTGDI(NT_SUCCESS(st), \
  50. "gdi32!vToUnicodeN(MACRO): Rtl func. failed\n"); \
  51. }
  52. #else
  53. #define vToUnicodeN( awchDst, cwchDst, achSrc, cchSrc ) \
  54. { \
  55. RtlMultiByteToUnicodeN( \
  56. (PWSZ)(awchDst),(ULONG)((cwchDst)*sizeof(WCHAR)), \
  57. (PULONG)NULL,(PSZ)(achSrc),(ULONG)(cchSrc)); \
  58. }
  59. #endif