-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathunicode.c
More file actions
29 lines (29 loc) · 841 Bytes
/
unicode.c
File metadata and controls
29 lines (29 loc) · 841 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include <stdio.h>
#include <string.h>
#include <wchar.h>
#include <locale.h>
#include <stdlib.h>
#include <ctype.h>
void to_mono(const char *s) {
for (int i = 0; s[i]; i++) {
if (islower(s[i])) wprintf(L"%lc", s[i] + 0x1D68A - 'a');
else if (isupper(s[i])) wprintf(L"%lc", s[i] + 0x1D670 - 'A');
else wprintf(L"%c", s[i]);
}
wprintf(L"\n");
}
void to_italic(const char *s) {
for (int i = 0; s[i]; i++) {
if (islower(s[i])) wprintf(L"%lc", s[i] + 0x1D44E - 'a');
else if (isupper(s[i])) wprintf(L"%lc", s[i] + 0x1D434 - 'A');
else wprintf(L"%c", s[i]);
}
wprintf(L"\n");
}
int main(const int argc, const char **argv) {
if (argc < 3) return -1;
setlocale(LC_ALL, "zh_CN.UTF-8");
if (!strcmp(argv[1], "mono")) to_mono(argv[2]);
else if (!strcmp(argv[1], "italic")) to_italic(argv[2]);
return 0;
}