From 700139404044730a726af7cd57e3d2dbc07871ea Mon Sep 17 00:00:00 2001 From: delthas Date: Sat, 8 Oct 2022 12:42:40 +0200 Subject: Replace non-UTF8 chars with the Unicode replacement character tcell does not handle non-UTF8 chars well, so we explicitly replace them when getting the messages to avoid passing them to tcell down the line. --- irc/channel.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/irc/channel.go b/irc/channel.go index c4a9e6f..b318784 100644 --- a/irc/channel.go +++ b/irc/channel.go @@ -4,6 +4,8 @@ import ( "bufio" "fmt" "net" + "strings" + "unicode" ) const chanCapacity = 64 @@ -16,6 +18,7 @@ func ChanInOut(conn net.Conn) (in <-chan Message, out chan<- Message) { r := bufio.NewScanner(conn) for r.Scan() { line := r.Text() + line = strings.ToValidUTF8(line, string([]rune{unicode.ReplacementChar})) msg, err := ParseMessage(line) if err != nil { continue -- cgit v1.2.3