Display incoming UTF-8 natively, convert only outgoing to ISO-8859-1
- Stop converting incoming text to ISO-8859-1 for display - Terminal is UTF-8, so pass through directly (åäö, Cyrillic, etc.) - Keep ISO-8859-1 conversion only for outgoing messages - Add irc.log to .gitignore
This commit is contained in:
@@ -1,2 +1,4 @@
|
|||||||
*.o
|
*.o
|
||||||
irc
|
irc
|
||||||
|
irc.log
|
||||||
|
chartest
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ A lightweight terminal IRC client written in C with automatic charset conversion
|
|||||||
- **SIGWINCH** handling (terminal resize)
|
- **SIGWINCH** handling (terminal resize)
|
||||||
- **Ident** — works with system identd on port 113
|
- **Ident** — works with system identd on port 113
|
||||||
- **Real name** from passwd GECOS field
|
- **Real name** from passwd GECOS field
|
||||||
|
- **Charset logger** — logs raw incoming bytes with hex dump and detected encoding to `irc.log`
|
||||||
|
|
||||||
## Building
|
## Building
|
||||||
|
|
||||||
@@ -41,6 +42,8 @@ Port defaults to 6667.
|
|||||||
| Ctrl-U | Kill to beginning (yank buffer) |
|
| Ctrl-U | Kill to beginning (yank buffer) |
|
||||||
| Ctrl-K | Kill to end (yank buffer) |
|
| Ctrl-K | Kill to end (yank buffer) |
|
||||||
| Ctrl-Y | Yank (paste) |
|
| Ctrl-Y | Yank (paste) |
|
||||||
|
| Ctrl-P | Page up (scroll back in history) |
|
||||||
|
| Ctrl-N | Page down (scroll forward) |
|
||||||
| Ctrl-D | Quit (EOF) |
|
| Ctrl-D | Quit (EOF) |
|
||||||
| Ctrl-C | Quit prompt (Y/N, default N) |
|
| Ctrl-C | Quit prompt (Y/N, default N) |
|
||||||
|
|
||||||
@@ -53,6 +56,7 @@ Port defaults to 6667.
|
|||||||
| `/msg <target> <text>` | Send private message |
|
| `/msg <target> <text>` | Send private message |
|
||||||
| `/nick <newnick>` | Change nickname |
|
| `/nick <newnick>` | Change nickname |
|
||||||
| `/mode <target> <modes>` | Set mode |
|
| `/mode <target> <modes>` | Set mode |
|
||||||
|
| `/names [#channel]` | List users in channel |
|
||||||
| `/whois <nick>` | WHOIS query |
|
| `/whois <nick>` | WHOIS query |
|
||||||
| `/wii <nick>` | Extended WHOIS (queries remote server) |
|
| `/wii <nick>` | Extended WHOIS (queries remote server) |
|
||||||
| `/quit [reason]` | Quit (default: "See you later") |
|
| `/quit [reason]` | Quit (default: "See you later") |
|
||||||
|
|||||||
-32
@@ -1,32 +0,0 @@
|
|||||||
#include <stdio.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <termios.h>
|
|
||||||
|
|
||||||
int main(void)
|
|
||||||
{
|
|
||||||
struct termios orig, raw;
|
|
||||||
tcgetattr(STDIN_FILENO, &orig);
|
|
||||||
raw = orig;
|
|
||||||
raw.c_lflag &= ~(ICANON | ECHO);
|
|
||||||
raw.c_cc[VMIN] = 1;
|
|
||||||
tcsetattr(STDIN_FILENO, TCSANOW, &raw);
|
|
||||||
|
|
||||||
printf("Press keys (Ctrl-D to quit):\n");
|
|
||||||
for (;;) {
|
|
||||||
unsigned char c;
|
|
||||||
if (read(STDIN_FILENO, &c, 1) <= 0 || c == 0x04)
|
|
||||||
break;
|
|
||||||
printf(" dec=%3d hex=0x%02X oct=%03o", c, c, c);
|
|
||||||
if (c >= 32 && c < 127)
|
|
||||||
printf(" char='%c'", c);
|
|
||||||
else if (c >= 0xC0)
|
|
||||||
printf(" (UTF-8 lead byte, %d-byte seq)",
|
|
||||||
c < 0xE0 ? 2 : c < 0xF0 ? 3 : 4);
|
|
||||||
else if ((c & 0xC0) == 0x80)
|
|
||||||
printf(" (UTF-8 continuation)");
|
|
||||||
printf("\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
tcsetattr(STDIN_FILENO, TCSANOW, &orig);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
@@ -441,10 +441,9 @@ static void handle_line(char *line)
|
|||||||
size_t rawlen = strlen(line);
|
size_t rawlen = strlen(line);
|
||||||
log_raw(line, rawlen);
|
log_raw(line, rawlen);
|
||||||
|
|
||||||
char converted[BUF_SIZE];
|
/* Incoming text is displayed as-is (terminal is UTF-8).
|
||||||
|
* No conversion needed for display. */
|
||||||
to_iso8859_1((unsigned char *)line, strlen(line),
|
char *converted = line;
|
||||||
converted, sizeof(converted));
|
|
||||||
|
|
||||||
if (strncmp(converted, "PING ", 5) == 0) {
|
if (strncmp(converted, "PING ", 5) == 0) {
|
||||||
irc_send_raw("PONG %s", converted + 5);
|
irc_send_raw("PONG %s", converted + 5);
|
||||||
|
|||||||
Reference in New Issue
Block a user