Results 1 to 7 of 7

Thread: How to save a file in UTF with BOM?

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

    Default How to save a file in UTF with BOM?

    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 
    Is not working. How to save a file in UTF-8 with BOM.

  2. #2
    Join Date
    Oct 2009
    Posts
    364
    Thanks
    10
    Thanked 37 Times in 36 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How to save a file in UTF with BOM?

    what exactly is BOM?

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

    Default Re: How to save a file in UTF with BOM?

    My program generates a HTML file in UTF-8 format. I want to later edit this file in notepad++, but it must be in UTF-8 with BOM. This will allow me on Polish characters.

  4. #4
    Join Date
    Oct 2009
    Posts
    364
    Thanks
    10
    Thanked 37 Times in 36 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How to save a file in UTF with BOM?

    do you get the correct encoding disregarding the BOM?
    can you put the BOM in manually?

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

    Default Re: How to save a file in UTF with BOM?

    Quote Originally Posted by schnitzel View Post
    do you get the correct encoding disregarding the BOM?
    Yep, I have UTF-8.

    Quote Originally Posted by schnitzel View Post
    can you put the BOM in manually?
    Yes, but I want it to be automatic.

  6. #6
    Join Date
    Nov 2010
    Posts
    20
    Thanks
    1
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to save a file in UTF with BOM?

    You are maybe looking for QTextStream::setGenerateByteOrderMark

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

    Alan_K (19th March 2011)

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

    Default Re: How to save a file in UTF with BOM?

    That's it. Works, thanks.

Similar Threads

  1. save Qimage in a file
    By OverTheOCean in forum Qt Programming
    Replies: 7
    Last Post: 20th March 2011, 23:42
  2. Not enough space to save file
    By ^NyAw^ in forum Qt Programming
    Replies: 1
    Last Post: 24th May 2010, 23:14
  3. Save QWidget as PDF file
    By chapu in forum Newbie
    Replies: 2
    Last Post: 26th April 2010, 04:35
  4. Save Icon in a file
    By prashant in forum Qt Programming
    Replies: 1
    Last Post: 27th November 2009, 18:07
  5. How to check a file for changes since last save
    By nmather in forum General Programming
    Replies: 2
    Last Post: 21st April 2007, 23:43

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.