summaryrefslogtreecommitdiff
path: root/quackleio
diff options
context:
space:
mode:
authorJohn Fultz <jfultz@wolfram.com>2016-07-02 22:45:25 -0500
committerJohn Fultz <jfultz@wolfram.com>2016-07-02 23:03:25 -0500
commit6640912578e4d5a4567fd7ae20f0da2bf6fb7058 (patch)
tree5da79565dd86a42fb63cacaa066bbe52db88ddf7 /quackleio
parent9da3b038985650bf1f16409abd0a0a7f35de5a62 (diff)
More character encoding stuff
A few character encoding things that had still been missed, and preliminary support for #character-encoding in GCG files.
Diffstat (limited to 'quackleio')
-rw-r--r--quackleio/gcgio.cpp7
1 files changed, 7 insertions, 0 deletions
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;