Created
May 1, 2014 16:38
-
-
Save MartinDelille/a9d9d8228135191ba4dd to your computer and use it in GitHub Desktop.
Encoding test around œ
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Copyright (C) 2012-2014 Phonations | |
* License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher | |
*/ | |
#include <QFileInfo> | |
#include <QDebug> | |
#include <QTextCodec> | |
#include <QDir> | |
#include <QDomDocument> | |
#include <QTextCodec> | |
//#include <QCoreApplication> | |
#include <QDebug> | |
int main(int argc, char *argv[]) | |
{ | |
for(int i = 30; i < 255; i++) | |
qDebug() << i << (char)i; | |
QString s = "œ"; | |
qDebug() << s; | |
qDebug() << s.at(0).unicode(); | |
qDebug() << (unsigned char)s.toUtf8().at(0); | |
qDebug() << (unsigned char)s.toStdString().c_str()[0] << s.toStdString().c_str(); | |
qDebug() << (unsigned char)s.toLatin1().at(0) << s.toLatin1(); | |
qDebug() << s.toUcs4().at(0); | |
QTextCodec *codec = QTextCodec::codecForName("latin9"); | |
QByteArray array = codec->fromUnicode(s); | |
qDebug() << (unsigned char)array.at(0); | |
foreach(QByteArray encoding, QTextCodec::availableCodecs()) { | |
QTextCodec *codec = QTextCodec::codecForName(encoding); | |
QByteArray array = codec->fromUnicode(s); | |
if(array.length()) | |
qDebug() << encoding << (unsigned char)array.at(0); | |
else | |
qDebug() << encoding << "problem"; | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment