Uploaded image for project: 'Qt Creator'
  1. Qt Creator
  2. QTCREATORBUG-14094

char array incorrectly displayed as UTF-8 string

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • Not Evaluated
    • Qt Creator 3.4.0-rc1
    • Qt Creator 3.3.1
    • Debugger
    • None
    • Ubuntu 14.04, 64 bit.
    • 3e02f8ec2ee88af43437a736c234b2091f13cfba

    Description

      Consider following code:

      int main()
      {
         char const str1[] = "ั‚ะตัั‚";
      
         return 0;
      }
      

      "str1" initialized with some non-ascii UTF-8 string.

      By default Qt Creator displays strings as Latin-1 strings, so it's displayed as gibberish (see attached screenshot "char_array_default.png").

      Qt Creator has convenient feature in debugger: change variable display format to treat it specially. For string-like types it's possible to select string encoding: Latin-1, UTF-8 or UCS-4.

      The issue is that for char arrays this settings changes visualization from string type to array type, see attached screenshot "char_array_as_utf8.png"

      Workaround to see "char[]" types as UTF-8 strings is to add expression evaluator, where convert "char[]" type to "char *", and select encoding for it.

      Attachments

        1. char_array_as_utf8.png
          143 kB
          Vladimir Rutsky
        2. char_array_default.png
          144 kB
          Vladimir Rutsky
        3. test.cpp
          0.1 kB
          Vladimir Rutsky
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            hjk hjk
            vrutsky Vladimir Rutsky
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes