kdecore: rely solely on Katie's locale codec detection

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2021-03-24 00:16:24 +02:00
parent 07bd46509f
commit 825449e174
5 changed files with 3 additions and 50 deletions

View file

@ -40,7 +40,6 @@ check_include_files(unistd.h HAVE_UNISTD_H) # various
check_include_files(stdint.h HAVE_STDINT_H) # various
check_include_files(sys/time.h HAVE_SYS_TIME_H) # various
check_include_files(langinfo.h HAVE_LANGINFO_H) # kdecore
# TODO: separate to config-x11.h
macro_bool_to_01(X11_XTest_FOUND HAVE_XTEST) # kdecore

View file

@ -40,12 +40,6 @@ configure_file(
${CMAKE_CURRENT_BINARY_DIR}/BackendsConfig.h
)
# Configure checks for localization
configure_file(
localization/config-localization.h.cmake
${CMAKE_CURRENT_BINARY_DIR}/config-localization.h
)
include_directories(
${KDE4_KDECORE_INCLUDES}
${KDE4_KDEUI_INCLUDES}

View file

@ -1 +0,0 @@
#cmakedefine01 HAVE_LANGINFO_H

View file

@ -24,8 +24,6 @@
#include "klocale_p.h"
#include "config-localization.h"
#include <math.h>
#include <locale.h>
@ -35,9 +33,6 @@
#ifdef HAVE_TIME_H
#include <time.h>
#endif
#if HAVE_LANGINFO_H
#include <langinfo.h>
#endif
#include <QtCore/QTextCodec>
#include <QtCore/QFile>
@ -2604,17 +2599,7 @@ void KLocalePrivate::initEncoding()
m_codecForEncoding = 0;
// This all made more sense when we still had the EncodingEnum config key.
QByteArray codeset = systemCodeset();
if (!codeset.isEmpty()) {
QTextCodec* codec = QTextCodec::codecForName(codeset);
if (codec) {
setEncoding(codec->mibEnum());
}
} else {
setEncoding(QTextCodec::codecForLocale()->mibEnum());
}
if (!m_codecForEncoding) {
kWarning() << "Cannot resolve system encoding, defaulting to ISO 8859-1.";
@ -2625,25 +2610,6 @@ void KLocalePrivate::initEncoding()
Q_ASSERT(m_codecForEncoding);
}
QByteArray KLocalePrivate::systemCodeset() const
{
QByteArray codeset;
#if HAVE_LANGINFO_H
// Qt since 4.2 always returns 'System' as codecForLocale and KDE (for example
// KEncodingFileDialog) expects real encoding name. So on systems that have langinfo.h use
// nl_langinfo instead, just like Qt compiled without iconv does. Windows already has its own
// workaround
codeset = nl_langinfo(CODESET);
if ((codeset == "ANSI_X3.4-1968") || (codeset == "US-ASCII")) {
// means ascii, "C"; QTextCodec doesn't know, so avoid warning
codeset = "ISO-8859-1";
}
#endif
return codeset;
}
void KLocalePrivate::initFileNameEncoding()
{
// If the following environment variable is set, assume all filenames
@ -2656,10 +2622,10 @@ void KLocalePrivate::initFileNameEncoding()
return;
}
QByteArray lang = qgetenv("LC_ALL");
if (lang.isEmpty() || lang == "C") {
if (lang.isEmpty()) {
lang = qgetenv("LC_CTYPE");
}
if (lang.isEmpty() || lang == "C") {
if (lang.isEmpty()) {
lang = qgetenv("LANG");
}
if (lang.endsWith("UTF-8")) {

View file

@ -1056,11 +1056,6 @@ protected:
*/
virtual void initFileNameEncoding();
/**
* @internal Returns the system codeset.
*/
virtual QByteArray systemCodeset() const;
public:
/**