/[james]/archive/guilib/wstring.c
ViewVC logotype

Contents of /archive/guilib/wstring.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 16 - (show annotations) (download) (as text)
Mon Feb 10 22:56:40 2003 UTC (21 years, 8 months ago) by james
File MIME type: text/x-csrc
File size: 1126 byte(s)
Initial import.

1 /* wstring.c */
2
3 #include "wstring.h"
4
5 /*
6 wchar_t *wstrchr(wchar_t const *str, wchar_t c)
7 {
8 for (; *str != c; str++)
9 if (*str == 0)
10 return NULL;
11 return str;
12 }
13
14
15 int wstrcmp(wchar_t const *str1, wchar_t const *str2)
16 {
17 for (; *str1 == *str2; str1++, str2++)
18 if (*str1 == 0)
19 return 0;
20 return *str1 - *str2;
21 }
22
23
24 wchar_t *wstrcpy(wchar_t *str1, wchar_t const *str2)
25 {
26 wchar_t *p = str1;
27
28 while (*str1++ = *str2++)
29 ;
30 return p;
31 }
32
33
34 size_t wstrlen(wchar_t *str)
35 {
36 wchar_t *p = str;
37
38 while (*p != 0)
39 p++;
40 return p - str;
41 }
42
43
44 wchar_t *wstrncpy(wchar_t *str1, wchar_t const *str2, unsigned int count)
45 {
46 wchar_t *p = str1;
47
48 while ((count--) && (*str1++ = *str2++))
49 ;
50 return p;
51 }
52 */
53
54 int wfputc(wchar_t c, FILE *stream)
55 {
56 if (fputc(c & 0xff, stream) == EOF) return EOF;
57 if (fputc((c >> 8) & 0xff, stream) == EOF) return EOF;
58 if (fputc((c >> 16) & 0xff, stream) == EOF) return EOF;
59 if (fputc((c >> 24) & 0xff, stream) == EOF) return EOF;
60 return c;
61 }
62
63
64 int wfputs(wchar_t *str, FILE *stream)
65 {
66 while (*str != 0)
67 {
68 wfputc(*str, stream);
69 str++;
70 }
71 return 0;
72 }

  ViewVC Help
Powered by ViewVC 1.1.26