Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. General talk
  3. Qt 6
  4. How to determine system encoding in Qt 6?
Servers for Qt installer are currently down

How to determine system encoding in Qt 6?

Scheduled Pinned Locked Moved Solved Qt 6
3 Posts 2 Posters 265 Views 1 Watching
  • 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.
  • T Offline
    T Offline
    theGreatWhiteShark
    wrote on last edited by
    #1

    Previously, I could use QTextCodec::codecForLocale() to determine the local encoding in an OS-agnostic way. The main use case was to include it in the application log. At least two times this was key to reproduce an user issue concerning file import. But for Qt6 QTextCodec is only available as a Qt5 compatibility feature.

    Is there a new, Qt 6 native way to determine the system's local encoding? I couldn't find it in the docs (or other forum posts)

    1 Reply Last reply
    0
    • Axel SpoerlA Offline
      Axel SpoerlA Offline
      Axel Spoerl
      Moderators
      wrote on last edited by
      #2

      I'd do the following:

      const QLocale locale = QLocale::system();
      const auto encoding = QStringConverter::encodingForName(locale.name().toUtf8());
      

      Software Engineer
      The Qt Company, Oslo

      1 Reply Last reply
      2
      • T Offline
        T Offline
        theGreatWhiteShark
        wrote last edited by
        #3

        Thanks a lot!

        1 Reply Last reply
        0
        • T theGreatWhiteShark has marked this topic as solved

        • Login

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