mirror of
https://bitbucket.org/smil3y/kdelibs.git
synced 2025-02-23 18:32:49 +00:00
kdecore: rely solely on Katie's locale codec detection
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
07bd46509f
commit
825449e174
5 changed files with 3 additions and 50 deletions
|
@ -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(stdint.h HAVE_STDINT_H) # various
|
||||||
|
|
||||||
check_include_files(sys/time.h HAVE_SYS_TIME_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
|
# TODO: separate to config-x11.h
|
||||||
macro_bool_to_01(X11_XTest_FOUND HAVE_XTEST) # kdecore
|
macro_bool_to_01(X11_XTest_FOUND HAVE_XTEST) # kdecore
|
||||||
|
|
|
@ -40,12 +40,6 @@ configure_file(
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/BackendsConfig.h
|
${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(
|
include_directories(
|
||||||
${KDE4_KDECORE_INCLUDES}
|
${KDE4_KDECORE_INCLUDES}
|
||||||
${KDE4_KDEUI_INCLUDES}
|
${KDE4_KDEUI_INCLUDES}
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
#cmakedefine01 HAVE_LANGINFO_H
|
|
|
@ -24,8 +24,6 @@
|
||||||
|
|
||||||
#include "klocale_p.h"
|
#include "klocale_p.h"
|
||||||
|
|
||||||
#include "config-localization.h"
|
|
||||||
|
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <locale.h>
|
#include <locale.h>
|
||||||
|
|
||||||
|
@ -35,9 +33,6 @@
|
||||||
#ifdef HAVE_TIME_H
|
#ifdef HAVE_TIME_H
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#endif
|
#endif
|
||||||
#if HAVE_LANGINFO_H
|
|
||||||
#include <langinfo.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <QtCore/QTextCodec>
|
#include <QtCore/QTextCodec>
|
||||||
#include <QtCore/QFile>
|
#include <QtCore/QFile>
|
||||||
|
@ -2604,17 +2599,7 @@ void KLocalePrivate::initEncoding()
|
||||||
m_codecForEncoding = 0;
|
m_codecForEncoding = 0;
|
||||||
|
|
||||||
// This all made more sense when we still had the EncodingEnum config key.
|
// This all made more sense when we still had the EncodingEnum config key.
|
||||||
|
setEncoding(QTextCodec::codecForLocale()->mibEnum());
|
||||||
QByteArray codeset = systemCodeset();
|
|
||||||
|
|
||||||
if (!codeset.isEmpty()) {
|
|
||||||
QTextCodec* codec = QTextCodec::codecForName(codeset);
|
|
||||||
if (codec) {
|
|
||||||
setEncoding(codec->mibEnum());
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
setEncoding(QTextCodec::codecForLocale()->mibEnum());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!m_codecForEncoding) {
|
if (!m_codecForEncoding) {
|
||||||
kWarning() << "Cannot resolve system encoding, defaulting to ISO 8859-1.";
|
kWarning() << "Cannot resolve system encoding, defaulting to ISO 8859-1.";
|
||||||
|
@ -2625,25 +2610,6 @@ void KLocalePrivate::initEncoding()
|
||||||
Q_ASSERT(m_codecForEncoding);
|
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()
|
void KLocalePrivate::initFileNameEncoding()
|
||||||
{
|
{
|
||||||
// If the following environment variable is set, assume all filenames
|
// If the following environment variable is set, assume all filenames
|
||||||
|
@ -2656,10 +2622,10 @@ void KLocalePrivate::initFileNameEncoding()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QByteArray lang = qgetenv("LC_ALL");
|
QByteArray lang = qgetenv("LC_ALL");
|
||||||
if (lang.isEmpty() || lang == "C") {
|
if (lang.isEmpty()) {
|
||||||
lang = qgetenv("LC_CTYPE");
|
lang = qgetenv("LC_CTYPE");
|
||||||
}
|
}
|
||||||
if (lang.isEmpty() || lang == "C") {
|
if (lang.isEmpty()) {
|
||||||
lang = qgetenv("LANG");
|
lang = qgetenv("LANG");
|
||||||
}
|
}
|
||||||
if (lang.endsWith("UTF-8")) {
|
if (lang.endsWith("UTF-8")) {
|
||||||
|
|
|
@ -1056,11 +1056,6 @@ protected:
|
||||||
*/
|
*/
|
||||||
virtual void initFileNameEncoding();
|
virtual void initFileNameEncoding();
|
||||||
|
|
||||||
/**
|
|
||||||
* @internal Returns the system codeset.
|
|
||||||
*/
|
|
||||||
virtual QByteArray systemCodeset() const;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Reference in a new issue