[Qt-interest] QString::fromLocal8Bit vs locales
Imre PÉNTEK
pentek.imre at gmail.com
Sat Aug 20 10:20:23 CEST 2011
Hello,
and thank you for your answer.
péntek 19 augusztus 2011 17:47:27 dátummal Thiago Macieira az alábbiakat írta:
> You forgot QCoreApplication.
Well, I didn't forgot. I can't tell how and why a QCoreApplication would help
me, but anyways I modified my code like this:
--- main.cpp.old 2011-08-20 10:07:50.231971947 +0200
+++ main.cpp 2011-08-20 10:05:30.316945836 +0200
@@ -1,10 +1,13 @@
#include <QTextCodec>
#include <QTextStream>
+#include <QCoreApplication>
#define MYPRINT(x) {const char *p=reinterpret_cast<const char
*>(x);write(1,p,strlen(p));}
-int main()
+int main(int argc, char **argv)
{
+ QCoreApplication app(argc,argv);
+
char be[1024];
QTextStream out(stdout,QIODevice::WriteOnly);
ssize_t l=read(0,be,1023);
now at least both fromLocal8Bit and fromUtf8 works when native charset is
UTF-8. However when native charset is Latin-2 none of them are correct.
FromLocal8Bit now only deals with ascii characters:
input was: e9e1fbf5faf6fcf3ed616c6d6166610a, éáűőúöüóíalmafa
fromLocal8Bit:616c6d6166610a, almafa
fromUtf8:
efbfbdefbfbdefbfbdefbfbdefbfbdefbfbdefbfbdefbfbdefbfbd616c6d6166610a,
[garbage]almafa
--
With regards: Imre Péntek
E-Mail: pentek.imre at gmail.com
More information about the Qt-interest-old
mailing list