LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   [Qt] String encoding trouble in gnome (https://www.linuxquestions.org/questions/programming-9/%5Bqt%5D-string-encoding-trouble-in-gnome-863595/)

almatic 02-18-2011 02:35 PM

[Qt] String encoding trouble in gnome
 
Hi,

I have a little qt frontend to wipe files with secure delete from within filemanagers. It does work from kde-filemanagers and stand-alone, but not from gnome. When I open files over a nautilus action, the filename ends up with a kind of html-encoding (%20 for space and so on). Please see this image to understand what I mean.

http://s3.directupload.net/file/u/22...y83qyk_png.htm

I have tried different encoding conversion functions like QString::latin1 and playing around with the options variables %F and %U with or without quotes. But it's all trial and error since I don't know where this encoding comes from.

Any ideas ?

Here is the relevant code, it's also highlighted in the image.

Code:

void qwipe::init(int argc, char* argv[])
{
    for(int i=1;i<argc;i++)
    {
        QListWidgetItem *newItem = new QListWidgetItem;
        newItem->setText(argv[i]);
        fileView->insertItem(i-1, newItem);
    }
}


Tinkster 02-18-2011 04:41 PM

Hi,

Haven't played w/ Qt in a while, but if memory serves me right
you may want to have a play w/:
setPlainText

So, if you find your strings to contain %something sequences
(so if run under Nauseous) use the method above to convert
your "url" to an actual file-system string.

HIH.


Cheers,
Tink

graemef 02-19-2011 01:26 AM

First I'd suggest taking your argv[i] and storing into an intermediary QString.
What do you get?
I suspect the problem is there and so you might want to look at QString::fromLocal8Bit(). Possibly look at QTextCodec::codecForLocale()


All times are GMT -5. The time now is 04:09 PM.