restored iconv support
This commit is contained in:
parent
388eb1761f
commit
edb4150b33
1 changed files with 10 additions and 32 deletions
|
@ -163,44 +163,23 @@ namespace mapnik {
|
||||||
public:
|
public:
|
||||||
explicit transcoder (std::string const& encoding)
|
explicit transcoder (std::string const& encoding)
|
||||||
{
|
{
|
||||||
//desc_ = iconv_open("UCS-2",encoding.c_str());
|
#ifdef MAPNIK_DEBUG
|
||||||
|
std::cerr << "ENCODING = " << encoding << "\n";
|
||||||
|
#endif
|
||||||
|
desc_ = iconv_open("UTF-8",encoding.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
std::wstring transcode(std::string const& input) const
|
std::wstring transcode(std::string const& input) const
|
||||||
{
|
{
|
||||||
//return to_unicode(input);
|
if (desc_ == iconv_t(-1)) return to_unicode(input);
|
||||||
return to_unicode(input);
|
|
||||||
/*
|
std::string buf(input.size() /* * sizeof(wchar_t)*/,0);
|
||||||
std::string buf(input.size() * 2,0);
|
|
||||||
size_t inleft = input.size();
|
size_t inleft = input.size();
|
||||||
const char * in = input.data();
|
const char * in = input.data();
|
||||||
size_t outleft = buf.size();
|
size_t outleft = buf.size();
|
||||||
char * out = const_cast<char*>(buf.data());
|
char * out = const_cast<char*>(buf.data());
|
||||||
|
|
||||||
iconv(desc_,&in,&inleft,&out,&outleft);
|
iconv(desc_,&in,&inleft,&out,&outleft);
|
||||||
|
std::wstring unicode = to_unicode(buf);
|
||||||
std::string::const_iterator itr = buf.begin();
|
|
||||||
std::string::const_iterator end = buf.end();
|
|
||||||
wchar_t wch = 0;
|
|
||||||
bool state = false;
|
|
||||||
std::wstring unicode;
|
|
||||||
size_t num_char = buf.size() - outleft;
|
|
||||||
for ( ; itr != end; ++itr)
|
|
||||||
{
|
|
||||||
if (!state)
|
|
||||||
{
|
|
||||||
wch = (*itr & 0xff);
|
|
||||||
state = true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
wch |= *itr << 8 ;
|
|
||||||
unicode.push_back(wchar_t(wch));
|
|
||||||
state = false;
|
|
||||||
}
|
|
||||||
if (!num_char--) break;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef USE_FRIBIDI
|
#ifdef USE_FRIBIDI
|
||||||
if (unicode.length() > 0)
|
if (unicode.length() > 0)
|
||||||
{
|
{
|
||||||
|
@ -210,12 +189,11 @@ namespace mapnik {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
return unicode;
|
return unicode;
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
~transcoder()
|
~transcoder()
|
||||||
{
|
{
|
||||||
//iconv_close(desc_);
|
if (desc_ != iconv_t(-1)) iconv_close(desc_);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
Loading…
Reference in a new issue