Results 1 to 19 of 19

Thread: Qt creator not showing Arabic alphabets.

  1. #1
    Join Date
    Dec 2012
    Posts
    197
    Thanks
    25
    Thanked 41 Times in 33 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Qt creator not showing Arabic alphabets.

    Hello friends,
    im working on a Qt app where i have to use Arabic alphabets in the combobox.
    i add the alphabets as follows :
    Qt Code:
    1. ui->symb_combo->addItem("أدخل الرمز");
    To copy to clipboard, switch view to plain text mode 
    i have a problem , when i read the symbol selected from that combo box and try to print it
    it doesnt show. instead of showing : أدخل الرمز it shows : ???? ?????
    so as you can see ,it is showing " ?? " instead on Arabic alphabets
    any help is appreciated to solve this problem.
    Thanks in advance.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Qt creator not showing Arabic alphabets.

    QtCreator has nothing to do with this. You just didn't inform QString how to convert your input to Unicode. What encoding does your source code use?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Dec 2012
    Posts
    197
    Thanks
    25
    Thanked 41 Times in 33 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Qt creator not showing Arabic alphabets.

    Thanks for your reply,
    but excuse me for this question , what do you exactly mean by What encoding does your source code use? ?
    how do i know that ?

    if i open the .cpp file in notepad and check the encoding , it shows UTF-8( if thats what you mean ).
    im just adding أدخل الرمز to my combo box and then retrieving and printing

    Qt Code:
    1. ui->symb_combo->addItem("أدخل الرمز");
    2.  
    3. void method()
    4. {
    5. QString symb;
    6. symb = ui->symb_combo->currentText();
    7. qDebug () << ""+symb;
    8. }
    To copy to clipboard, switch view to plain text mode 

    but i get ?? instead of the symbol


    Added after 1 28 minutes:


    Still waiting for help guys
    i saw a thread stating a solution for this problem but unfortunately it didn't work...
    it consisted of 2 steps:
    1st : save the source file as UTF-8 encoding
    2nd : inform Qt creator of this by adding this line of code to the main.cpp
    Qt Code:
    1. QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8"));
    To copy to clipboard, switch view to plain text mode 
    is the * QTextCodec::setCodecForCStrings * method usable ? does it exist in Qt 5.1 ?
    Last edited by toufic.dbouk; 4th September 2013 at 17:31.

  4. #4
    Join Date
    Dec 2012
    Posts
    197
    Thanks
    25
    Thanked 41 Times in 33 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Qt creator not showing Arabic alphabets.

    Hello again,
    im still trying to figure it out...
    Another approach seems to be adding this line:
    Qt Code:
    1. QTextCodec::setCodecForCStrings(QTextCodec::codecForName("CP1256") );
    To copy to clipboard, switch view to plain text mode 
    CP1256 is the unicode encoding for Arabic
    but unfortunately it didn't work...
    i appropriate any help guys.

  5. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Qt creator not showing Arabic alphabets.

    Qt Code:
    1. QString str = QString::fromUtf8("your arabic text goes here");
    To copy to clipboard, switch view to plain text mode 

    BTW. CP1256 is not any "unicode encoding" for arabic.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  6. #6
    Join Date
    Dec 2012
    Posts
    197
    Thanks
    25
    Thanked 41 Times in 33 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Qt creator not showing Arabic alphabets.

    hey wysota,
    i tried this before posting a new thread on the forum
    Qt Code:
    1. QString str = QString::fromUtf8("your arabic text goes here");
    To copy to clipboard, switch view to plain text mode 
    this doesnt seem to solve my problem
    any other ideas ?
    and what is CP1256 ? something that helps in converting from non unicode to unicode ?

    Just to make it clear if its not, my Arabic text appears in the combo box, but when i retrieve it print it ( as mentioned in the above posts) it gives *??* instead.

    example:
    Qt Code:
    1. QString str = QString::fromUtf8("أدخل الرمز");
    2. ui->Symb_combo->addItem(str);
    3. void print() {
    4. QString symb;
    5. symb = ui->Symb_combo->currentText();
    6. qDebug () << ""+symb;
    7. }
    To copy to clipboard, switch view to plain text mode 

    this reults in : "???? ?????"
    Last edited by toufic.dbouk; 4th September 2013 at 19:36.

  7. #7
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Qt creator not showing Arabic alphabets.

    Quote Originally Posted by toufic.dbouk View Post
    hey wysota,
    i tried this before posting a new thread on the forum
    Qt Code:
    1. QString str = QString::fromUtf8("your arabic text goes here");
    To copy to clipboard, switch view to plain text mode 
    this doesnt seem to solve my problem
    In that case you're not using UTF-8 encoding. You should get somewhat more familiar with your system and learn what encoding it uses.

    and what is CP1256 ? something that helps in converting from non unicode to unicode ?
    http://lmgtfy.com?q=CP1256

    Just to make it clear if its not, my Arabic text appears in the combo box, but when i retrieve it print it ( as mentioned in the above posts) it gives *??* instead.
    Your console doesn't know how to print it, you have to convert it to something it understands (which brings us back to the original problem of learning what encoding the system uses).
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  8. #8
    Join Date
    Dec 2012
    Posts
    197
    Thanks
    25
    Thanked 41 Times in 33 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Qt creator not showing Arabic alphabets.

    alright thank you Wysota
    but can you tell me how to find what encoding does my system use ?
    when i open the .cpp file in notepad it shows UTF-8 encoding.
    Even if i did that through Qt creator ( edit > select encoding >UTF-8 ) i still get the same problem.
    i really need help here
    Thanks for all your replies Wysota.
    Last edited by toufic.dbouk; 4th September 2013 at 20:03.

  9. #9
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Qt creator not showing Arabic alphabets.

    Quote Originally Posted by toufic.dbouk View Post
    but can you tell me how to find what encoding does my system use ?
    Consult your operating system manual or contact technical service of the system vendor.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  10. #10
    Join Date
    Dec 2012
    Posts
    197
    Thanks
    25
    Thanked 41 Times in 33 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Qt creator not showing Arabic alphabets.

    sounds complicated but okay ill do that.
    but you can explain to me why does the Arabic text appears in the combo box fields but doesn't appear while printing it ?
    this is really confusing , and im saving the .cpp file( source code that contains the Arabic text as UTF-8 ) so i guess that
    should make the encoding of this file as UTF-8 and it stills gives *??? * when printing the text in the combo box.
    i wish i wasted all this time on a technical problem instead of such problem....
    thanks for your help and please let me know if you have any other ideas to try , i really tried more than the 3 trails mentioned in this post.

  11. #11
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Qt creator not showing Arabic alphabets.

    Quote Originally Posted by toufic.dbouk View Post
    but you can explain to me why does the Arabic text appears in the combo box fields but doesn't appear while printing it ?
    Because your GUI (Qt) uses Unicode and your console doesn't.

    this is really confusing , and im saving the .cpp file( source code that contains the Arabic text as UTF-8 )
    Encoding of the source file has nothing to do with this. Even if you encoded your file in ISO8859-2, your console would still not understand unicode nor the default conversion qDebug() uses to print strings.

    i wish i wasted all this time on a technical problem instead of such problem....
    This is a technical problem. The problem is that you don't know how your system works. This problem is completely unrelated to Qt, it only manifests itself while using Qt. You'd still have this same problem if you wanted to dump any text encoded in encoding A to a console (or other target) that uses a different encoding.

    thanks for your help and please let me know if you have any other ideas to try , i really tried more than the 3 trails mentioned in this post.
    Ask google about "default encoding for Arabic windows system" as I'm assuming we're talking about Windows. Then ask QTextCodec nicely to convert the given unicode text to this encoding before dumping it to the console. A good initial guess if you can't use web search engines is to try the code page you already mentioned in this thread.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  12. #12
    Join Date
    Dec 2012
    Posts
    197
    Thanks
    25
    Thanked 41 Times in 33 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Qt creator not showing Arabic alphabets.

    Hi Wysota ,

    i don't think we are on the same page...
    im compiling and ruining the app in debug mode ,
    and im printing it using qDebug() to show in the Application Output in Qt creator ( thats where the ?? are shown )
    should i try it on the cmd console ? or it wont matter ?

    since your first reply to this post was , what is your source code unicode , i assumed to try and change it and see what happens
    if i change the source code unicode through notepad, the Arabic text wont appear even in the combo box.

    im not familiar with all this encoding stuff , but ill look further into this after solving my problem cuz i really have to go through this application ASAP.

    Ask google about "default encoding for Arabic windows system" as I'm assuming we're talking about Windows. Then ask QTextCodec nicely to convert the given unicode text to this encoding before dumping it to the console.
    ill google this and see what happens...

    Best Regards Wysota.

  13. #13
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Qt creator not showing Arabic alphabets.

    Quote Originally Posted by toufic.dbouk View Post
    i don't think we are on the same page...
    im compiling and ruining the app in debug mode ,
    and im printing it using qDebug() to show in the Application Output in Qt creator ( thats where the ?? are shown )
    should i try it on the cmd console ? or it wont matter ?
    You can do whatever you want. I don't care really. I already told you that the problem is text encoding. I know that the source encoding in your case is Unicode, I have no idea what the target encoding on your system is. There is nothing more I can do for you apart repeating that you need to output textual content from qDebug in an encoding your target device understands. Whether it is the pipe Qt Creator opens to your application, the cmd application or anything else, is a secondary issue.

    since your first reply to this post was , what is your source code unicode , i assumed to try and change it and see what happens
    My first reply was assuming that the text you get in your UI is wrong. You can ignore everything I said prior to you saying you had a problem with qDebug.

    im not familiar with all this encoding stuff
    Yeah, well... if you are/want to be a software developer then you should get familiar with "this encoding stuff". Especially if you're coming from a country that uses an alphabet different than American English is using.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  14. The following user says thank you to wysota for this useful post:

    toufic.dbouk (4th September 2013)

  15. #14
    Join Date
    Dec 2012
    Posts
    197
    Thanks
    25
    Thanked 41 Times in 33 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Qt creator not showing Arabic alphabets.

    Thanks , ill try to figure it out and get back to this ost to mark it as SOLVED


    Added after 44 minutes:


    Hey Wysota ,
    just wanna update you with everyone who is viewing this post that i showed the result instead of qDebug() in a table view ,
    and it actually showed the Arabic alphabetic.

    if this changes anything with the previous discussions
    Best Regards.
    Last edited by toufic.dbouk; 4th September 2013 at 22:08.

  16. #15
    Join Date
    Dec 2012
    Posts
    197
    Thanks
    25
    Thanked 41 Times in 33 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Qt creator not showing Arabic alphabets.

    one thing that might be helpful in this post is trying the flowing :
    1st: save all source files as UTF-8 encoding
    2nd: tools -> options -> text editor -> behavior -> set default encoding to UTF-8

    but still when using the qDebug () it shows : ??? instead of Arabic letters
    but at least now if you retrieve the data ina table view , Arabic letters will appear
    if anyone knows how to solve the qDebug() issue please let me know

    Thanks.
    Last edited by toufic.dbouk; 7th September 2013 at 23:19.

  17. #16
    Join Date
    Dec 2008
    Posts
    15
    Thanks
    1
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Qt creator not showing Arabic alphabets.

    Qt requires that the encoding of the code files ( .h, .cpp ) to be the same as the "codecForCStrings" to be able to read the Arabic text in the correct manner.

    so, I recommend that you put the following line of code in the main() function (after) initializing QApplication object and (before) showing any widgets/windows:

    Qt Code:
    1. QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8") );
    To copy to clipboard, switch view to plain text mode 

    that's if the encoding of your files are UTF-8

    but if they are set to the default encoding of the system, which is "windows-1256" in windows-xp, i think, then you should write it:

    Qt Code:
    1. QTextCodec::setCodecForCStrings(QTextCodec::codecForName("windows-1256") );
    To copy to clipboard, switch view to plain text mode 

  18. #17
    Join Date
    Dec 2012
    Posts
    197
    Thanks
    25
    Thanked 41 Times in 33 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Qt creator not showing Arabic alphabets.

    @ahmedb
    Check the first 3-4 posts in this thread , we already went through your suggestion.
    Thanks for your concern.

  19. #18
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Qt creator not showing Arabic alphabets.

    Quote Originally Posted by toufic.dbouk View Post
    if anyone knows how to solve the qDebug() issue please let me know
    There is no qDebug() issue, it simply outputs what you tell it to using the default locale encoding for QStrings. If your console, i.e. the place your output appears, does not understand the encoding used then that is not the fault of qDebug.

    This example Qt4 program:
    Qt Code:
    1. #include <QtCore>
    2. int main(int argc, char **argv)
    3. {
    4. QCoreApplication app(argc, argv);
    5. QString test = QString::fromUtf8("\u0660\u0661\u0662\u0663\u0664\u0665\u0666\u0667\u0668\u0669");
    6. qDebug() << test;
    7. return 0;
    8. }
    To copy to clipboard, switch view to plain text mode 
    Outputs "٠١٢٣٤٥٦٧٨٩" just fine on my UTF-8 enabled Linux console because the the default codec works well.

    My US English Windows XP machine is expecting a different encoding and outputs this by default:
    Qt Code:
    1. Y:\tt>debug\tt.exe
    2. "??????????"
    To copy to clipboard, switch view to plain text mode 
    where the '?' stands in for a unicode code point that has no equivalent in the Windows 8-bit code page.
    The behaviour of the Windows console is variable beast that depends on selected fonts and other settings etc. You can try this... Start a CMD shell, ensure its font is set to "Lucida Console" or "Consolas", execute "chcp 65001", then run your program from the command line and see if the output is better.

  20. #19
    Join Date
    Dec 2012
    Posts
    197
    Thanks
    25
    Thanked 41 Times in 33 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Qt creator not showing Arabic alphabets.

    @ChrisW67
    i tried the example you mentioned above :
    Qt Code:
    1. QString test = QString::fromUtf8("\u0660\u0661\u0662\u0663\u0664\u0665\u0666\u0667\u0668\u0669");
    2. qDebug() << test;
    To copy to clipboard, switch view to plain text mode 
    i get this warning : character represented by universal-character-name '\u0669' cannot be represented in the current code page (1252)

    tried setting the encoding to UTF-8 and to windows-1252
    but still all i get in the Qt Application Output Console is : "??????????"

    Quote Originally Posted by ChrisW67
    then run your program from the command line and see if the output is better
    How to do that ? locate the test.exe file generated by Qt and execute it ? or do i have to run qmake on the .pro file ? build and compile then run ?

Similar Threads

  1. Qt Creator 2.2.1 not showing variables on Mac
    By dave2k in forum Qt Tools
    Replies: 1
    Last Post: 22nd August 2011, 21:41
  2. random alphabets
    By hema in forum Newbie
    Replies: 3
    Last Post: 20th July 2011, 17:23
  3. Regex to filter words containing english alphabets
    By dipeshtech in forum Qt Programming
    Replies: 12
    Last Post: 1st April 2011, 00:24
  4. How use unicode in Arabic language?
    By mismael85 in forum Qt Programming
    Replies: 1
    Last Post: 18th November 2010, 13:08
  5. Showing QMainWindow without showing a child QWidget
    By discostu in forum Qt Programming
    Replies: 3
    Last Post: 4th March 2007, 09:03

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.