author | Markus Bröker <mbroeker@largo.dyndns.tv> |
Thu, 16 Apr 2009 12:51:15 +0200 | |
changeset 83 | 220d76d0d672 |
parent 77 | 49e0babccb23 |
child 114 | 6f6850407ccf |
permissions | -rw-r--r-- |
0 | 1 |
/** |
77 | 2 |
* utf8.c |
9
c3fecc82ade6
standard tags for git projects
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
8
diff
changeset
|
3 |
* Copyright (C) 2008 Markus Broeker |
0 | 4 |
*/ |
5 |
||
6 |
#include <stdio.h> |
|
7 |
#include <stdlib.h> |
|
8 |
#include <wchar.h> |
|
9 |
#include <locale.h> |
|
10 |
||
11 |
#ifndef u_char |
|
12 |
typedef unsigned char u_char; |
|
13 |
#endif |
|
14 |
||
15 |
int main () |
|
16 |
{ |
|
17 |
char dest[4]; |
|
18 |
||
19 |
wchar_t *str = L"Unicode Example with german umlauts: ÄÖÜäöü߀\n"; |
|
20 |
||
21 |
if (!setlocale (LC_CTYPE, "")) { |
|
22 |
perror ("SETLOCALE"); |
|
23 |
return EXIT_FAILURE; |
|
24 |
} |
|
25 |
||
26 |
printf ("%ls", str); |
|
27 |
||
28 |
while (*str != '\n') { |
|
29 |
dest[0] = 0; |
|
30 |
dest[1] = 0; |
|
31 |
dest[2] = 0; |
|
32 |
dest[3] = 0; |
|
33 |
if (wctomb (dest, (*str)) == -1) |
|
48
b94d657a9acb
Policy Inonsistency on many files
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
9
diff
changeset
|
34 |
return EXIT_FAILURE; |
0 | 35 |
|
36 |
printf ("%lc -> [%4X] (%2X:%2X:%2X:%2X)\n", |
|
37 |
*str, *str, (u_char) dest[0], (u_char) dest[1], (u_char) dest[2], (u_char) dest[3]); |
|
38 |
str++; |
|
39 |
} |
|
40 |
||
41 |
printf ("DIFF: %d : 0x%2X\n", 0x40, 0x40); |
|
8
96d16dfe787a
We use return EXIT_SUCCESS instead of return 0
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
0
diff
changeset
|
42 |
|
96d16dfe787a
We use return EXIT_SUCCESS instead of return 0
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
0
diff
changeset
|
43 |
return EXIT_SUCCESS; |
0 | 44 |
} |