Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-41006

Need wide-character version of qgetenv() (qwgetenv?)

    XMLWordPrintable

Details

    • Suggestion
    • Resolution: Done
    • P4: Low
    • 5.10.0 Alpha
    • 5.3.1
    • Core: Other
    • None
    • b12fd1fa9d0b64e3cb66fa68c85392dbde8e175b

    Description

      On Windows, it's possible for environment variables to be set to UTF-16 strings; consider for instance TEMP=C:\权时. These are mangled if passed through qgetenv() and then QString::fromLocal8Bit(). (Unfortunately, I don't have any more detail than that; I personally don't have a Windows development environment.)

      Per http://msdn.microsoft.com/en-us/library/tb2sfw2z.aspx, there is a wgetenv_s to go with the getenv_s} that {{qgetenv currently uses. It sounds like it's more efficient (in an application whose entry point is _wmain or equivalent, which I assume is true for Qt/Windows applications) to use _exclusively _wgetenv_s, so I'd like to suggest the following cluster of changes:

      • Add qwgetenv which returns a QString. On Windows, this calls _wgetenv_s; on non-Windows, it calls getenv followed by QString::fromLocal8Bit.
      • Change the existing qgetenv, qEnvironmentVariableIsSet, and qEnvironmentVariableIsEmpty so that, on Windows, they also use _wgetenv_s. qgetenv would feed the result through QString::toLocal8Bit before returning.
      • As long as we're messing with this anyway, a full complement of QString/QByteArray/const char */const wchar_t * overloads for all of these functions would be nice.

      Attachments

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              kkohne Kai Köhne
              zackw Zack Weinberg
              Votes:
              1 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes