Support for Japanese character in savegame

1.3.x
Rafael 7 years ago
parent cb1ae08394
commit 6e3f7118a9
  1. 44
      SavegameData.cpp
  2. 4
      SnapmaticPicture.cpp
  3. 7
      SnapmaticWidget.ui

@ -17,6 +17,8 @@
*****************************************************************************/
#include "SavegameData.h"
#include <QTextCodec>
#include <QDebug>
#include <QFile>
SavegameData::SavegameData(QString fileName, QObject *parent) : QObject(parent), savegameFileName(fileName)
@ -62,7 +64,6 @@ bool SavegameData::readingSavegame()
savegameOk = true;
}
}
saveFile->close();
saveFile->deleteLater();
delete saveFile;
@ -71,10 +72,43 @@ bool SavegameData::readingSavegame()
QString SavegameData::getSavegameDataString(QByteArray savegameHeader)
{
QByteArray savegameUsefulBytes = savegameHeader.left(savegameHeaderLength);
savegameUsefulBytes.replace(QByteArray::fromHex("00"),"");
savegameUsefulBytes.replace(QByteArray::fromHex("01"),"");
return QString::fromLatin1(savegameUsefulBytes);
QString savegameTitle;
QByteArray savegameBytes = savegameHeader.left(savegameHeaderLength);
QList<QByteArray> savegameBytesList = savegameBytes.split(char(0x01));
savegameBytes = savegameBytesList.at(1);
int savegameLength = savegameBytes.length();
int parsedBytes = 0;
while (parsedBytes <= savegameLength)
{
QList<QByteArray> parseByteList;
parseByteList.append(savegameBytes.mid(parsedBytes-1, 1));
parseByteList.append(savegameBytes.mid(parsedBytes-2, 1));
if (parseByteList.at(0).toHex() == "00")
{
// Latin character
savegameTitle.append(QString::fromLatin1(parseByteList.at(1)));
}
else if (parseByteList.at(0).toHex() == "30")
{
// Japanese character
QByteArray japaneseHex;
japaneseHex.append(QByteArray::fromHex("A5"));
japaneseHex.append(parseByteList.at(1));
savegameTitle.append(QTextCodec::codecForName("EUC-JP")->toUnicode(japaneseHex));
}
else
{
// Unsupported
}
parsedBytes = parsedBytes + 2;
parseByteList.clear();
}
savegameBytesList.clear();
savegameBytes.clear();
return savegameTitle;
}
bool SavegameData::readingSavegameFromFile(QString fileName)

@ -190,7 +190,7 @@ QString SnapmaticPicture::getSnapmaticJSONString(QByteArray jsonBytes)
QByteArray jsonUsefulBytes = jsonBytes;
jsonUsefulBytes.replace((char)0x00, "");
jsonUsefulBytes.replace((char)0x0c, "");
return QString::fromLatin1(jsonUsefulBytes);
return QString::fromUtf8(jsonUsefulBytes);
}
QString SnapmaticPicture::getSnapmaticTIDEString(QByteArray tideBytes)
@ -198,7 +198,7 @@ QString SnapmaticPicture::getSnapmaticTIDEString(QByteArray tideBytes)
QByteArray tideUsefulBytes = tideBytes;
tideUsefulBytes.remove(0, 4);
QList<QByteArray> tideUsefulBytesList = tideUsefulBytes.split(char(0x00));
return QString::fromLatin1(tideUsefulBytesList.at(0));
return QString::fromUtf8(tideUsefulBytesList.at(0));
}
bool SnapmaticPicture::readingPictureFromFile(QString fileName)

@ -65,6 +65,13 @@
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="cmdCopy">
<property name="text">
<string>Copy</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="cmdDelete">
<property name="text">

Loading…
Cancel
Save