Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to force QString to serialize as UTF-8?

How to force QString to serialize as UTF-8?

Scheduled Pinned Locked Moved General and Desktop
qstringqdatastream
1 Posts 1 Posters 1.2k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Resurr3ctionR Offline
    Resurr3ctionR Offline
    Resurr3ction
    wrote on last edited by
    #1

    Hello, the QString serializes by default (via QDataStream) as UTF-16. This inflates the resulting file to more than twice the original size if the original string was encoded as UTF-8 which has variable size of each character. Is there a way to let QString be serialized in UTF-8 (or encoding of user's choosing) instead of default UTF-16? I am aware of a work-arounds such as storing cstring or QByteArray and reconsdtructing the QString from them when deserializing but I am looking for more direct approach.

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved