2008/9/8 Chris Cannam <[EMAIL PROTECTED]>:
> Use qstrtostr and strtoqstr for strings that are being stored for
> later display in the GUI, and that we may want to convert back and
> forth more than once. (Reason: preserves UTF8 encoding in both
> directions.)
>
> Use toStdString() when the target is a std::string for immediate
> display at the console (not in the GUI) or for use in an error message
> or as a file or directory path. (Reason: creates std::string
> directly; uses local encoding; shorter than toLocal8Bit().data())
>
today, filesystems use utf8 too, as do some terminals (command-lines),
so I believe toLocal8 is appropriate here as well.
> Use toLocal8Bit().data() when the target is a file or directory path
> in a system call or similar. (Reason: uses local encoding; creates
> C-style string as desired)
>
> I think. Any advance on that from anyone else?
>
>
Now ... .toStdString() does not work here.
("error: 'const class QString' has no member named 'toStdString'")
It did not work with debians default qt4, nor with the sources
I compiled myself, to be shure I'd had STL enabled.
I still have the line at hand I used to configure:
./configure --prefix=/usr -stl -system-sqlite -qt3support
-optimized-qmake -silent
output from ./configure --help:
-no-stl ............ Do not compile STL support.
* -stl ............... Compile STL support.
Maybe it's just me, but if not, then we should care about it.
Do I miss a compiler option?
If it's related to QT3_SUPPORT, then I guess toStdString() will
disappear soon too.
I'd suggest to use the functions, I implemented in Strings.h.
That way, we know at least, what we are doing and would have a central place, in
case we needed modifications:
for gui-strings:
qStrToStrUtf8( &qstr );
qStrToCharPtrUtf8( &qstr );
for file-acces / system-call:
qStrToStrLocal8( &qstr );
qStrToCharPtrLocal8( &qstr );
Now we know the target encoding.
But what is the source encoding ?
With QString I think we don't have to think about it, but
if we converted std:string to QString, we had to do
something like QString.fromUtf8( stdStr ) , in case stdStr was utf8 encoded.
I thinks it's best, to use utf8 where possible.
Only convert to target encoding (utf8 / local8) at the very end of the chain.
Convert to utf8 as soon as a string has been received. (not necessary
with QStrings I think)
Maybe we should thus convert some functions to accept QStrings instead ?
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Rosegarden-devel mailing list
[email protected] - use the link below to unsubscribe
https://lists.sourceforge.net/lists/listinfo/rosegarden-devel