Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
qtws26_logo

The Qt Event of the Year: Qt World Summit 2026

Save Your Spot >
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. How to compile utf16 source file?
Qt 6.12 LTS is out! See what's new in the release blog

How to compile utf16 source file?

Scheduled Pinned Locked Moved Qt Creator and other tools
3 Posts 2 Posters 1.3k 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.
  • ? Offline
    ? Offline
    A Former User
    wrote on last edited by
    #1

    If I used utf16 for sources , I'm getting many errors like stray '\377' in program

    1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      Qt 5 expects your source code to be encoded in UTF-8.

      In Qt 4, you can use "setCodecForCStrings":http://qt-project.org/doc/qt-4.8/qtextcodec.html#setCodecForCStrings and setCodecForLocale (that method is also available in Qt 5).

      Apart from Qt, you may also need to make your compiler aware of the unusual encoding.

      (Z(:^

      1 Reply Last reply
      0
      • ? Offline
        ? Offline
        A Former User
        wrote on last edited by
        #3

        like that:
        g++ -finput-charset=CP1251 -fexec-charset=CP1251 -o test my.cpp

        i was trying, and I dropped the case.

        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
        • Unsolved