Results 1 to 11 of 11

Thread: Polish chars in the HTML generated by Qt.

  1. #1
    Join Date
    Aug 2010
    Location
    Poland
    Posts
    19
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Windows

    Default Polish chars in the HTML generated by Qt.

    Hi. Look at my code. I have a very big problem, namely the encoding of the HTML file. So, polish chars in QMessageBox works correctly, but in text of the "out" no so good.
    Qt Code:
    1. QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8"));
    2. QTextCodec::setCodecForLocale(QTextCodec::codecForName("UTF-8"));
    3. QTextCodec::setCodecForTr(QTextCodec::codecForName("UTF-8"));
    To copy to clipboard, switch view to plain text mode 
    Example:
    Qt Code:
    1. out << "<h2>INFORMACJA O GOTOWOŚCI DZIECKA<br />DO PODJĘCIA NAUKI W SZKOLE PODSTAWOWEJ</h2>\n";
    To copy to clipboard, switch view to plain text mode 
    looks:
    INFORMACJA O GOTOWOÂŒCI DZIECKA
    DO PODJÊCIA NAUKI W SZKOLE PODSTAWOWEJ
    Ê =/= Ę

    I coded the files in UTF-8 with BOM. Polish characters, which are get from the checboxe's label works correctly.
    Last edited by Alan_K; 20th March 2011 at 18:20. Reason: Hide source code; all works correctly

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

    Default Re: Polish chars in the HTML generated by Qt.

    AFAIK QTextStream uses its own codec. Have a look at QTextStream::setCodec().
    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
    Aug 2010
    Location
    Poland
    Posts
    19
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Polish chars in the HTML generated by Qt.

    You can clearly? I have already tried to use this feature, but I do not know how to change the encoding on correct. UTF-8, Windows-1250 not working and all other attempt wail.

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

    Default Re: Polish chars in the HTML generated by Qt.

    What is the encoding of your source code file?
    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.


  5. #5
    Join Date
    Aug 2010
    Location
    Poland
    Posts
    19
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Polish chars in the HTML generated by Qt.

    Quote Originally Posted by wysota View Post
    What is the encoding of your source code file?
    "System"

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

    Default Re: Polish chars in the HTML generated by Qt.

    I'm not asking what QtCreator shows, I'm asking what the encoding is. There is no encoding called "System". Since you're using Windows it's probably UTF-8. See if wrapping your strings in QString::fromUtf8() helps.
    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.


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

    Alan_K (20th March 2011)

  8. #7
    Join Date
    Aug 2010
    Location
    Poland
    Posts
    19
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Polish chars in the HTML generated by Qt.

    Quote Originally Posted by wysota View Post
    I'm not asking what QtCreator shows, I'm asking what the encoding is. There is no encoding called "System". Since you're using Windows it's probably UTF-8. See if wrapping your strings in QString::fromUtf8() helps.
    Not working, but QString::fromAscii() works correctly. Thanks.

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

    Default Re: Polish chars in the HTML generated by Qt.

    Well, it shouldn't. Use fromUtf8() and remove your calls that set explicit codecs for C strings.
    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. #9
    Join Date
    Aug 2009
    Location
    Greece
    Posts
    69
    Thanks
    2
    Thanked 14 Times in 14 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Polish chars in the HTML generated by Qt.

    Quote Originally Posted by wysota View Post
    Since you're using Windows it's probably UTF-8. See if wrapping your strings in QString::fromUtf8() helps.
    I know for sure that in greek Windows Xp the system default is always Windows-1253. Can't tell for sure about polish but in a similar case the QString::fromLocal8bit is more suitable, Of course there is the option to change your sources encodings to UTF-8

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

    Default Re: Polish chars in the HTML generated by Qt.

    fromLocal8Bit() won't be any good because local encodings change and the source file encoding stays the same. So using local8Bit() will fail if the file gets compiled on say... Linux with Chinese locale but fromUtf8() will work because the file is still encoded in utf-8 regardless of the settings of the computer (and its OS) it is opened on.
    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. #11
    Join Date
    Mar 2008
    Location
    Kraków, Poland
    Posts
    1,468
    Thanked 273 Times in 268 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Polish chars in the HTML generated by Qt.

    Maybe this is a compiler problem ?
    We have all sources coded in 1250 and this works perfectly :
    Qt Code:
    1. QTextCodec::setCodecForTr(QTextCodec::codecForName("Windows-1250"));
    2. QTextCodec::setCodecForCStrings(QTextCodec::codecForName("Windows-1250"));
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. Replacing polish diacritics in the string
    By kornicameister in forum Qt Programming
    Replies: 3
    Last Post: 8th February 2011, 16:54
  2. Qt for S60, problem with bold polish characters
    By Wiktor in forum Qt for Embedded and Mobile
    Replies: 0
    Last Post: 26th August 2009, 10:37
  3. Accessing generated pixmaps in html / Custom tooltips
    By Pieter from Belgium in forum Qt Programming
    Replies: 9
    Last Post: 1st August 2009, 16:24
  4. QDevelop needs Dutch and Polish translators
    By jlbrd in forum Qt-based Software
    Replies: 0
    Last Post: 4th December 2007, 18:54

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.