13,010
回編集
| 23行目: | 23行目: | ||
#include <QTextCodec> | #include <QTextCodec> | ||
// | // Shift-JISからUTF-8へデコードする場合 | ||
QTextCodec *codec = QTextCodec::codecForName(" | QByteArray SJISdata = "あいうえお"; | ||
QString str = codec->toUnicode( | QTextCodec *codec = QTextCodec::codecForName("Shift-JIS"); | ||
QString str = codec->toUnicode(SJISdata); | |||
// UTF-8からShift-JISへエンコードする場合 | // UTF-8からShift-JISへエンコードする場合 | ||
| 42行目: | 43行目: | ||
#include <QStringConverter> | #include <QStringConverter> | ||
// | // Shift-JISからUTF-8へデコードする場合 | ||
QStringDecoder decoder( | QByteArray SJISdata = "あいうえお"; | ||
QString str = decoder( | QStringDecoder decoder("Shift-JIS"); | ||
QString str = decoder(SJISdata); | |||
// UTF-8からShift-JISへエンコードする場合 | // UTF-8からShift-JISへエンコードする場合 | ||