Skip to content

Commit

Permalink
src/main: set qtextcodec for locale to utf-8
Browse files Browse the repository at this point in the history
On Windows QTextStream assumes the default code page for files without
a byte-order mark. This is much of UTF-8 since it isn't required and
sometimes isn't event recommended. On macOS and Linux this will almost
never be an issue because they use UTF-8 as the default code page.
Windows uses 1252 if you're an English speaker, if you're not then lol
good luck.

May God judge Bill Gates harshly for his crimes against unicode.

Closes #178
  • Loading branch information
ripose-jp committed Aug 17, 2023
1 parent 05d96ea commit e113c5c
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include <QFontDatabase>
#include <QMessageBox>
#include <QSettings>
#include <QTextCodec>

#if defined(Q_OS_WIN)
#include <QStandardPaths>
Expand Down Expand Up @@ -195,6 +196,10 @@ int main(int argc, char **argv)
/* Image Formats Windows */
QCoreApplication::addLibraryPath(DirectoryUtils::getProgramDirectory());
#endif

/* Always assume UTF-8 unless there's a BOM */
QTextCodec::setCodecForLocale(QTextCodec::codecForName("UTF-8"));

/* HiDPI support */
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
Expand Down

0 comments on commit e113c5c

Please sign in to comment.