From 6640912578e4d5a4567fd7ae20f0da2bf6fb7058 Mon Sep 17 00:00:00 2001 From: John Fultz Date: Sat, 2 Jul 2016 22:45:25 -0500 Subject: More character encoding stuff A few character encoding things that had still been missed, and preliminary support for #character-encoding in GCG files. --- quackleio/gcgio.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'quackleio/gcgio.cpp') diff --git a/quackleio/gcgio.cpp b/quackleio/gcgio.cpp index cafbf49..dfe23a0 100644 --- a/quackleio/gcgio.cpp +++ b/quackleio/gcgio.cpp @@ -43,6 +43,7 @@ Quackle::Game *GCGIO::read(QTextStream &stream, int flags) bool gameStarted = false; QString line; + stream.setCodec(QTextCodec::codecForName("ISO-8859-1")); while (!stream.atEnd()) { line = stream.readLine(); @@ -111,6 +112,11 @@ Quackle::Game *GCGIO::read(QTextStream &stream, int flags) incompleteRack = Util::encode(rackString); hasIncompleteRack = true; } + else if (line.startsWith("#character-encoding")) + { + QString encoding{line.right(line.length() - 20).trimmed()}; + stream.setCodec(QTextCodec::codecForName(encoding.toAscii())); + } } else if (line.startsWith(">")) { @@ -293,6 +299,7 @@ bool GCGIO::canRead(QTextStream &stream) const void GCGIO::write(const Quackle::Game &game, QTextStream &stream) { Quackle::PlayerList players = game.players(); + stream.setCodec(QTextCodec::codecForName("ISO-8859-1")); for (Quackle::PlayerList::iterator it = players.begin(); it != players.end(); ++it) { stream << "#player" << (*it).id() + 1 << " " << Util::uvStringToQString((*it).abbreviatedName()) << " " << Util::uvStringToQString((*it).name()) << endl; -- cgit v1.2.3