Skip to content

Commit 433a19b

Browse files
davispuhplfiorini
authored andcommitted
Always use QString::fromLocal8Bit for strings from POSIX API
Qt uses LC_* for locale and if they're set they take precedence over anything else, but sddm would set them to empty string if they weren't set before and that would ruin Qt system's locale causing use of wrong encoding. For proper i18n support need to ensure that LANG is set (from /etc/locale.conf) and then always use QString::fromLocal8Bit for all strings from POSIX API. I would recommend enabling QT_NO_CAST_FROM_ASCII and don't use QString(char *) but for POSIX API use fromLocal8Bit and for other APIs use respective encoding for them.
1 parent 476fc8a commit 433a19b

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/greeter/UserModel.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,9 @@ namespace SDDM {
7171

7272
// create user
7373
UserPtr user { new User() };
74-
user->name = QString(current_pw->pw_name);
75-
user->realName = QString::fromUtf8(current_pw->pw_gecos).split(",").first();
76-
user->homeDir = QString(current_pw->pw_dir);
74+
user->name = QString::fromLocal8Bit(current_pw->pw_name);
75+
user->realName = QString::fromLocal8Bit(current_pw->pw_gecos).split(",").first();
76+
user->homeDir = QString::fromLocal8Bit(current_pw->pw_dir);
7777
user->uid = int(current_pw->pw_uid);
7878
user->gid = int(current_pw->pw_gid);
7979
// if shadow is used pw_passwd will be 'x' nevertheless, so this

0 commit comments

Comments
 (0)