Qt-interest Archive, March 2007
Encoding trouble qDebug, console, WindowsXP/2000, cp1251, cp866, KOI8-R
Pages: Prev | 1 | 2 | Next
Message 16 in thread
On 3/29/07, SABROG <sabrog@xxxxxxxx> wrote:
> Yes, i see this in QtAssistant, actually i want write
> crossplatform program and i finding way how to detect
> locale and normal converting for this. QTextCodec::locale ()
> can return locale, but how return encoding ?
> Thank for links.
If you want to write crossplatform, I suggest you should avoid any
non-latin text in you source code as rule of thumb, and keep all the
i18n stuff in external resources (i.e. Qt translation files).
--
[ signature omitted ]
Message 17 in thread
On Thursday 29 March 2007 08:20, SABROG wrote:
> Yes, i see this in QtAssistant, actually i want write
> crossplatform program and i finding way how to detect
> locale and normal converting for this. QTextCodec::locale ()
> can return locale, but how return encoding ?
Qt doesn't have a function to return the encoding of the locale, only the
codec used for the locale (often this codec's name is just "System").
Just so that you know, Qt uses Unicode internall to store all textual data.
When reading from or writing to a file, Qt uses the
QTextCodec::codecForLocale() by default, unless told otherwise. In general,
you should not have to worry about text file encodings.
--
[ signature omitted ]
Message 18 in thread
SABROG ÐÐÑÐÑ:
> Yes, i see this in QtAssistant, actually i want write
> crossplatform program and i finding way how to detect
> locale and normal converting for this. QTextCodec::locale ()
> can return locale, but how return encoding ?
Using localized strings in source code in common, and localized log
files especially IMO is big mistake for crossplatform application.
--
[ signature omitted ]
Message 19 in thread
Hi,
> Using localized strings in source code in common, and localized log
> files especially IMO is big mistake for crossplatform application.
I'm afraid this can't work in a portable way, among other for the
reasons previously described: how does the compile interpret the string,
and how does the QString constructor interpret the string?
--
[ signature omitted ]
Message 20 in thread
Dimitri ÐÐÑÐÑ:
> Hi,
>
>> Using localized strings in source code in common, and localized log
>> files especially IMO is big mistake for crossplatform application.
>
> I'm afraid this can't work in a portable way, among other for the
Yes, of course if source string in cp1251 QString::fromLocal8Bit will
work properly only in cp1251 too.
> reasons previously described: how does the compile interpret the string,
> and how does the QString constructor interpret the string?
>
I can't forget the Korean strings in source :-).
--
[ signature omitted ]
Message 21 in thread
In Qt assistant write:
"toLocal8Bit() returns an 8-bit string using the system's local encoding."
So if my sources in Windows-1251 on linux text can be and KOI8-R and
UTF-8, if local set to this encodes ?
Nikolay Moskvichev wrote:
> Dimitri ÐÐÑÐÑ:
>> Hi,
>>
>>> Using localized strings in source code in common, and localized log
>>> files especially IMO is big mistake for crossplatform application.
>>
>> I'm afraid this can't work in a portable way, among other for the
>
> Yes, of course if source string in cp1251 QString::fromLocal8Bit will
> work properly only in cp1251 too.
>
>
>> reasons previously described: how does the compile interpret the
>> string, and how does the QString constructor interpret the string?
>>
>
> I can't forget the Korean strings in source :-).
--
[ signature omitted ]
Message 22 in thread
SABROG ÐÐÑÐÑ:
> In Qt assistant write:
>
> "toLocal8Bit() returns an 8-bit string using the system's local encoding."
>
> So if my sources in Windows-1251 on linux text can be and KOI8-R and
> UTF-8, if local set to this encodes ?
>
If system locale don't match your source files encoding, you don't get
your strings. As workaround you can load codec for cp1251, and use them
for translating your strings to unicode, like:
QTextCodec * codec = QTextCodec::codecForName ("CP1251");
(*out) << debugdate << QLatin1Char(' ') << codec->toUnicode(msg) <<
endl;
But if target system do not support cp1251, then you don't get codec.
This is one of reasons why using localised strings in source code is bad
practice. What wrong with QObject::tr ?
Keep your strings in english, and translate to local languages when
needed. (Read Qt Linguist Manual)
And especially about log files:
What if your application crashed in Albania ? If your log magically in
russian, then in most cases users can't read it, if log in albanian, I
would not like to say, but you forced to learn albanian then ;-)
--
[ signature omitted ]
Message 23 in thread
I know Albanian, Udaff.com learn me ;) (sorry, just Joke).
Padonkoffskiy yazik ne dlya menya :)
Really i be use English in log if be write application for all world,
but on my work i must write russian, becouse this program be use other
russian peoples, who can don't know english.
Nikolay Moskvichev wrote:
> What if your application crashed in Albania ? If your log magically in
> russian, then in most cases users can't read it, if log in albanian, I
> would not like to say, but you forced to learn albanian then ;-)
--
[ signature omitted ]
Message 24 in thread
Hi!
I am adding a Task Menu Extension to MyTextField in the Qt Designer.
MyTextField extends the QLineEdit. Is it possible to inherit or just
add my menu extension to the exist Task Menu Extension for QLineEdit?
Kjell Arne
--
[ signature omitted ]
Message 25 in thread
SABROG ÐÐÑÐÑ:
> Thanks all, i found solution:
>
> out = new QTextStream(log);
> out->setCodec("ISO 8859-1");
>
>
> And log file have Windows-1251 encode with my russian text :)
For me it looks like broken stream locale support.
--
[ signature omitted ]
Message 26 in thread
Thanks for help fromLocal8Bit() work how i and want.
Nikolay Moskvichev wrote:
> SABROG ÐÐÑÐÑ:
>> Thanks all, i found solution:
>>
>> out = new QTextStream(log);
>> out->setCodec("ISO 8859-1");
>>
>>
>> And log file have Windows-1251 encode with my russian text :)
>
> For me it looks like broken stream locale support.
--
[ signature omitted ]