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.

174 lines
2.0 KiB

  1. /*++
  2. Copyright (c) 1991 Microsoft Corporation
  3. Module Name:
  4. wstring.h
  5. Abstract:
  6. This module contains the prototypes for the wide character
  7. C-runtime support. Since there is no C-runtime support for
  8. wide characters, the functions here are wrappers to the
  9. single-byte counterparts
  10. Author:
  11. Ramon San Andres (Ramonsa) 07-Jun-1991
  12. Revision History:
  13. --*/
  14. typedef char wchar;
  15. typedef WCHAR wchar_t;
  16. typedef size_t wsize_t;
  17. long watol( const wchar *);
  18. wchar * wcschr(const wchar *, int);
  19. wchar * wcslwr(wchar *);
  20. wchar * wcsrchr(const wchar *, int);
  21. wchar * wcsupr(wchar *);
  22. wsize_t wcscspn(const wchar *, const wchar *);
  23. wsize_t wcsspn(const wchar *, const wchar *);
  24. wchar * wcsstr(const wchar *, const wchar *);
  25. int wctomb( char *s, wchar_t wchar );
  26. int mbtowc(wchar_t *pwc, const char *s, size_t n);
  27. wchar_t towupper( wchar_t wc);
  28. INLINE
  29. long
  30. watol(
  31. const wchar * p
  32. )
  33. {
  34. return atol( (char *)p );
  35. }
  36. INLINE
  37. wchar *
  38. wcschr (
  39. const wchar * p,
  40. int c
  41. )
  42. {
  43. return (wchar *)strchr( (char *)p, c);
  44. }
  45. INLINE
  46. wchar *
  47. wcslwr (
  48. wchar * p
  49. )
  50. {
  51. return (wchar *)strlwr( (char *)p );
  52. }
  53. INLINE
  54. wchar *
  55. wcsrchr (
  56. const wchar * p,
  57. int c
  58. )
  59. {
  60. return (char *)strrchr( (char *)p, c);
  61. }
  62. INLINE
  63. wchar *
  64. wcsupr (
  65. wchar * p
  66. )
  67. {
  68. return (char *)strupr( (char *)p );
  69. }
  70. INLINE
  71. wsize_t
  72. wcscspn (
  73. const wchar *p1,
  74. const wchar *p2
  75. )
  76. {
  77. return (wsize_t)strcspn( (char *)p1, (char *)p2);
  78. }
  79. INLINE
  80. wsize_t
  81. wcsspn (
  82. const wchar *p1,
  83. const wchar *p2
  84. )
  85. {
  86. return (wsize_t)strspn( (char *)p1, (char *)p2);
  87. }
  88. INLINE
  89. wchar *
  90. wcsstr (
  91. const wchar *p1,
  92. const wchar *p2
  93. )
  94. {
  95. return (wchar *)strstr( (char *)p1, (char *)p2);
  96. }
  97. INLINE
  98. int
  99. wctomb (
  100. char *s,
  101. wchar_t wchar
  102. )
  103. {
  104. if (s) {
  105. *s = (char)wchar;
  106. return 1;
  107. } else {
  108. return 0;
  109. }
  110. }
  111. INLINE
  112. int
  113. mbtowc (
  114. wchar_t *pwc,
  115. const char *s,
  116. size_t n
  117. )
  118. {
  119. UNREFERENCED_PARAMETER( n );
  120. if ( s && *s && (n > 0) ) {
  121. *pwc = (wchar_t)(*s);
  122. return 1;
  123. } else {
  124. return 0;
  125. }
  126. }
  127. INLINE
  128. wchar_t
  129. towupper(
  130. wchar_t wc
  131. )
  132. {
  133. return (wchar_t)toupper( (char)wc );
  134. }