[Qt-interest] How to check between "Text" and "Non-Text" File

Frederic Tingaud tingaud at gostai.com
Tue Apr 20 10:12:09 CEST 2010


yogesh upreti a écrit :
> Hallo Group,
> Can someone have any idea how to check between "Text" and "Non-Text" File?
> I am making an application, which gives a preview of files depending on
> type, i.e. if the file is a image, is shows a preview, if file is Text it
> should show top 10 lines in a text edit.
>
> I am able to recognise image file with extension, because normally in all
> the system it is like that, but I am not able to recognise Text files (as
> they can have any extension and some times no extension). I have to
> differentiate them with Binary data files (because when I start reading them
> my programme gets hang, or shows Garbage in text edit)
>
> Can someone tell me how to recognise that?
>
> Thanks
> Yogesh Upreti
>
>   
> ------------------------------------------------------------------------
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>   
For a first approximation you can check if there are character that
cannot be printed using QChar::isPrint ().

-- 
-------------------------------------------------------------------------------
Frederic TINGAUD
-------------------------------------------------------------------------------




More information about the Qt-interest-old mailing list