summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoralkamid <adamkli@gmail.com>2018-10-25 21:17:34 +0100
committerJohn Fultz <jfultz@wolfram.com>2019-07-22 02:01:45 -0700
commit6d706891ad95093f969edc11d6edcb45c97efc48 (patch)
tree4c2e65c90187554e26bd34fce1c1fc8b6f0befed
parente73218cfb59c0fdd6f08e9f2c577bdd0666fa4f9 (diff)
Make UTF-8 default encoding (and write pragma)
When reading, leave ISO-8859-1 as the default, and only change stream encoding if #character-encoding present. When writing, set encoding to UTF-8 and write #character-encoding pragma at the top of the .gcg file.
-rw-r--r--quackleio/gcgio.cpp3
-rw-r--r--quackleio/iotest/capp.gcg1
2 files changed, 3 insertions, 1 deletions
diff --git a/quackleio/gcgio.cpp b/quackleio/gcgio.cpp
index 4c08de6..54067ba 100644
--- a/quackleio/gcgio.cpp
+++ b/quackleio/gcgio.cpp
@@ -329,7 +329,8 @@ 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"));
+ stream.setCodec(QTextCodec::codecForName("UTF-8"));
+ stream << "#character-encoding UTF-8" << endl;
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;
diff --git a/quackleio/iotest/capp.gcg b/quackleio/iotest/capp.gcg
index 7c1a05c..f93fb3f 100644
--- a/quackleio/iotest/capp.gcg
+++ b/quackleio/iotest/capp.gcg
@@ -1,3 +1,4 @@
+#character-encoding UTF-8
#player1 Brian Brian Cappelletto
#player2 Pakorn Pakorn Nemitrmansuk
#title WSC 2001 Round 20: Brian Cappelletto vs. Pakorn Nemitrmansuk