Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
30
Task/Unicode-strings/C/unicode-strings.c
Normal file
30
Task/Unicode-strings/C/unicode-strings.c
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <locale.h>
|
||||
|
||||
/* wchar_t is the standard type for wide chars; what it is internally
|
||||
* depends on the compiler.
|
||||
*/
|
||||
wchar_t poker[] = L"♥♦♣♠";
|
||||
wchar_t four_two[] = L"\x56db\x5341\x4e8c";
|
||||
|
||||
int main() {
|
||||
/* Set the locale to alert C's multibyte output routines */
|
||||
if (!setlocale(LC_CTYPE, "")) {
|
||||
fprintf(stderr, "Locale failure, check your env vars\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
#ifdef __STDC_ISO_10646__
|
||||
/* C99 compilers should understand these */
|
||||
printf("%lc\n", 0x2708); /* ✈ */
|
||||
printf("%ls\n", poker); /* ♥♦♣♠ */
|
||||
printf("%ls\n", four_two); /* 四十二 */
|
||||
#else
|
||||
/* oh well */
|
||||
printf("airplane\n");
|
||||
printf("club diamond club spade\n");
|
||||
printf("for ty two\n");
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue