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:
2026-04-29 12:34:55 +02:00
parent 12a9127af8
commit 354f0eb8e9
4 changed files with 9 additions and 36 deletions
+2
View File
@@ -1,2 +1,4 @@
*.o
irc
irc.log
chartest
+4
View File
@@ -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 <target> <text>` | Send private message |
| `/nick <newnick>` | Change nickname |
| `/mode <target> <modes>` | Set mode |
| `/names [#channel]` | List users in channel |
| `/whois <nick>` | WHOIS query |
| `/wii <nick>` | Extended WHOIS (queries remote server) |
| `/quit [reason]` | Quit (default: "See you later") |
-32
View File
@@ -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;
}
+3 -4
View File
@@ -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);