Commit 41d866cc authored by Julian Andres Klode's avatar Julian Andres Klode
Browse files

Merge branch 'locale_decode_desc' into 'master'

Decode locale-encoded descriptions.

See merge request apt-team/python-apt!47
parents afed4b29 3cf10fd6
......@@ -31,6 +31,7 @@
#include <string>
#include <iostream>
#include <new>
#include <langinfo.h>
/**
* Exception class for almost all Python errors
......@@ -220,6 +221,12 @@ inline PyObject *CppPyString(const char *Str)
return PyString_FromString(Str);
}
inline PyObject *CppPyLocaleString(const std::string &Str)
{
char const * const codeset = nl_langinfo(CODESET);
return PyUnicode_Decode(Str.c_str(), Str.length(), codeset, "replace");
}
#if PY_MAJOR_VERSION >= 3
static inline PyObject *CppPyPath(const std::string &path)
{
......
......@@ -127,7 +127,7 @@ static PyObject *PkgRecordsGetShortDesc(PyObject *Self,void*) {
}
static PyObject *PkgRecordsGetLongDesc(PyObject *Self,void*) {
PkgRecordsStruct &Struct = GetStruct(Self,"LongDesc");
return (Struct.Last != 0) ? CppPyString(Struct.Last->LongDesc()) : 0;
return (Struct.Last != 0) ? CppPyLocaleString(Struct.Last->LongDesc()) : 0;
}
static PyObject *PkgRecordsGetName(PyObject *Self,void*) {
PkgRecordsStruct &Struct = GetStruct(Self,"Name");
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment