Skip to content

Commit 39d72ad

Browse files
authored
Merge pull request #1 from yhirose/utf8-support
UTF8 Support
2 parents e5179cb + a141e13 commit 39d72ad

File tree

4 files changed

+726
-50
lines changed

4 files changed

+726
-50
lines changed

example.cpp

+9-2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ static void completion(const char *buf, linenoiseCompletions *lc) {
88
if (buf[0] == 'h') {
99
linenoiseAddCompletion(lc,"hello");
1010
linenoiseAddCompletion(lc,"hello there");
11+
linenoiseAddCompletion(lc,"hello 😀");
12+
linenoiseAddCompletion(lc,"こんにちは");
1113
}
1214
}
1315

@@ -17,6 +19,11 @@ static const char *hints(const char *buf, int *color, int *bold) {
1719
*bold = 0;
1820
return " World";
1921
}
22+
if (!strcasecmp(buf,"こんにちは")) {
23+
*color = 35;
24+
*bold = 0;
25+
return " 世界";
26+
}
2027
return NULL;
2128
}
2229

@@ -61,7 +68,7 @@ int main(int argc, char **argv) {
6168

6269
while(1) {
6370
if (!async) {
64-
line = linenoise("hello> ");
71+
line = linenoise("😀 \033[32mhello\x1b[0m> ");
6572
if (line == NULL) break;
6673
} else {
6774
/* Asynchronous mode using the multiplexing API: wait for
@@ -116,7 +123,7 @@ int main(int argc, char **argv) {
116123
} else if (!strncmp(line, "/unmask", 7)) {
117124
linenoiseMaskModeDisable();
118125
} else if (line[0] == '/') {
119-
printf("Unreconized command: %s\n", line);
126+
printf("Unrecognized command: %s\n", line);
120127
}
121128
free((void*) line);
122129
}

0 commit comments

Comments
 (0)