Details
-
Suggestion
-
Resolution: Done
-
P4: Low
-
5.3.1
-
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
- is required for
-
QTBUG-62328 QtQml does not work with non Latin1 path in QML2_IMPORT_PATH variable
- Open
For Gerrit Dashboard: QTBUG-41006 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
141211,31 | Long live qEnvironmentVariable() | dev | qt/qtbase | Status: MERGED | +2 | 0 |
142989,20 | Use qEnvironmentVariable to get environment variables into a QString | dev | qt/qtbase | Status: ABANDONED | +2 | 0 |
168951,2 | Long live qEnvironmentVariable() | dev | qt/qtbase | Status: ABANDONED | -2 | 0 |