Source code of Windows XP (NT5)
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.

94 lines
2.0 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1996 - 1997.
  5. //
  6. // File: dbcs.hxx
  7. //
  8. // Contents: Macros for handling DBCS strings
  9. //
  10. // History: 10-24-96 DavidMun Created
  11. //
  12. //----------------------------------------------------------------------------
  13. #ifdef UNICODE
  14. #define PrevChar PrevCharW
  15. #define NextChar NextCharW
  16. #define IsLead IsLeadW
  17. #else // !UNICODE
  18. #define PrevChar PrevCharA
  19. #define NextChar NextCharA
  20. #define IsLead IsLeadA
  21. #endif // UNICODE
  22. //+---------------------------------------------------------------------------
  23. //
  24. // Function: PrevCharW
  25. //
  26. // Synopsis: Return [wszCur] - 1 or [wszStart] if [wszCur] is at or before
  27. // the start of the string.
  28. //
  29. // History: 10-24-96 DavidMun Created
  30. //
  31. //----------------------------------------------------------------------------
  32. inline LPWSTR
  33. PrevCharW(LPCWSTR wszStart, LPCWSTR wszCur)
  34. {
  35. if (wszCur > wszStart)
  36. {
  37. return (LPWSTR) (wszCur - 1);
  38. }
  39. return (LPWSTR) wszCur;
  40. }
  41. //+---------------------------------------------------------------------------
  42. //
  43. // Function: NextCharW
  44. //
  45. // Synopsis: Return [wszCur] + 1, or [wszCur] if it points to the end of
  46. // the string.
  47. //
  48. // History: 10-24-96 DavidMun Created
  49. //
  50. //----------------------------------------------------------------------------
  51. inline LPWSTR
  52. NextCharW(LPCWSTR wszCur)
  53. {
  54. if (*wszCur)
  55. {
  56. return (LPWSTR) (wszCur + 1);
  57. }
  58. return (LPWSTR) wszCur;
  59. }
  60. #define IsLeadW(wch) FALSE
  61. #define PrevCharA CharPrev
  62. #define NextCharA CharNext
  63. #define IsLeadA IsDBCSLeadByte
  64. HRESULT
  65. UnicodeToAnsi(
  66. LPSTR szTo,
  67. LPCWSTR pwszFrom,
  68. ULONG cbTo);
  69. HRESULT
  70. AnsiToUnicode(
  71. LPWSTR pwszTo,
  72. LPCSTR szFrom,
  73. LONG cchTo);