From 354f0eb8e9409e6972292e0012a2246707d85aab Mon Sep 17 00:00:00 2001 From: Anders Holck Date: Wed, 29 Apr 2026 12:34:55 +0200 Subject: [PATCH] Display incoming UTF-8 natively, convert only outgoing to ISO-8859-1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 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 --- .gitignore | 2 ++ README.md | 4 ++++ chartest.c | 32 -------------------------------- main.c | 7 +++---- 4 files changed, 9 insertions(+), 36 deletions(-) delete mode 100644 chartest.c diff --git a/.gitignore b/.gitignore index a35eec5..11a72cf 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ *.o irc +irc.log +chartest diff --git a/README.md b/README.md index 3dca16b..20dae70 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,7 @@ A lightweight terminal IRC client written in C with automatic charset conversion - **SIGWINCH** handling (terminal resize) - **Ident** — works with system identd on port 113 - **Real name** from passwd GECOS field +- **Charset logger** — logs raw incoming bytes with hex dump and detected encoding to `irc.log` ## Building @@ -41,6 +42,8 @@ Port defaults to 6667. | Ctrl-U | Kill to beginning (yank buffer) | | Ctrl-K | Kill to end (yank buffer) | | Ctrl-Y | Yank (paste) | +| Ctrl-P | Page up (scroll back in history) | +| Ctrl-N | Page down (scroll forward) | | Ctrl-D | Quit (EOF) | | Ctrl-C | Quit prompt (Y/N, default N) | @@ -53,6 +56,7 @@ Port defaults to 6667. | `/msg ` | Send private message | | `/nick ` | Change nickname | | `/mode ` | Set mode | +| `/names [#channel]` | List users in channel | | `/whois ` | WHOIS query | | `/wii ` | Extended WHOIS (queries remote server) | | `/quit [reason]` | Quit (default: "See you later") | diff --git a/chartest.c b/chartest.c deleted file mode 100644 index cc13adc..0000000 --- a/chartest.c +++ /dev/null @@ -1,32 +0,0 @@ -#include -#include -#include - -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; -} diff --git a/main.c b/main.c index 0c49917..9c5b1bf 100644 --- a/main.c +++ b/main.c @@ -441,10 +441,9 @@ static void handle_line(char *line) size_t rawlen = strlen(line); log_raw(line, rawlen); - char converted[BUF_SIZE]; - - to_iso8859_1((unsigned char *)line, strlen(line), - converted, sizeof(converted)); + /* Incoming text is displayed as-is (terminal is UTF-8). + * No conversion needed for display. */ + char *converted = line; if (strncmp(converted, "PING ", 5) == 0) { irc_send_raw("PONG %s", converted + 5);