Lines 27-32
Link Here
|
27 |
#include <unistd.h> |
27 |
#include <unistd.h> |
28 |
#include <unordered_set> |
28 |
#include <unordered_set> |
29 |
|
29 |
|
|
|
30 |
#include <cwchar> |
31 |
#include <sstream> |
32 |
#include <iomanip> |
33 |
|
30 |
#include "3rd-party/alphanum.hpp" |
34 |
#include "3rd-party/alphanum.hpp" |
31 |
#include "config.h" |
35 |
#include "config.h" |
32 |
#include "logger.h" |
36 |
#include "logger.h" |
Lines 521-529
std::wstring utils::utf8str2wstr(const std::string& ut
Link Here
|
521 |
std::wstring utils::str2wstr(const std::string& str) |
525 |
std::wstring utils::str2wstr(const std::string& str) |
522 |
{ |
526 |
{ |
523 |
const char* codeset = nl_langinfo(CODESET); |
527 |
const char* codeset = nl_langinfo(CODESET); |
|
|
528 |
|
529 |
//LOG(Level::DEBUG,"str2wstr, codeset=%s", codeset); |
530 |
|
524 |
struct stfl_ipool* ipool = stfl_ipool_create(codeset); |
531 |
struct stfl_ipool* ipool = stfl_ipool_create(codeset); |
525 |
std::wstring result = stfl_ipool_towc(ipool, str.c_str()); |
532 |
std::wstring result = stfl_ipool_towc(ipool, str.c_str()); |
526 |
stfl_ipool_destroy(ipool); |
533 |
stfl_ipool_destroy(ipool); |
|
|
534 |
|
535 |
LOG(Level::DEBUG, "str2wstr, str=%s", str.c_str()); |
536 |
|
527 |
return result; |
537 |
return result; |
528 |
} |
538 |
} |
529 |
|
539 |
|
Lines 534-539
std::string utils::wstr2str(const std::wstring& wstr)
Link Here
|
534 |
struct stfl_ipool* ipool = stfl_ipool_create(codeset.c_str()); |
544 |
struct stfl_ipool* ipool = stfl_ipool_create(codeset.c_str()); |
535 |
std::string result = stfl_ipool_fromwc(ipool, wstr.c_str()); |
545 |
std::string result = stfl_ipool_fromwc(ipool, wstr.c_str()); |
536 |
stfl_ipool_destroy(ipool); |
546 |
stfl_ipool_destroy(ipool); |
|
|
547 |
|
548 |
LOG(Level::DEBUG, "wstr2str, codeset=%s, str=%s", codeset.c_str(), result.c_str()); |
549 |
|
537 |
return result; |
550 |
return result; |
538 |
} |
551 |
} |
539 |
|
552 |
|
Lines 992-998
std::string utils::unescape_url(const std::string& url
Link Here
|
992 |
std::wstring utils::clean_nonprintable_characters(std::wstring text) |
1005 |
std::wstring utils::clean_nonprintable_characters(std::wstring text) |
993 |
{ |
1006 |
{ |
994 |
for (size_t idx = 0; idx < text.size(); ++idx) { |
1007 |
for (size_t idx = 0; idx < text.size(); ++idx) { |
995 |
if (!iswprint(text[idx])) |
1008 |
if (text[idx] == L'\u00A0') |
|
|
1009 |
text[idx] = L'\u0020'; |
1010 |
else if (!iswprint(text[idx])) |
996 |
text[idx] = L'\uFFFD'; |
1011 |
text[idx] = L'\uFFFD'; |
997 |
} |
1012 |
} |
998 |
return text; |
1013 |
return text; |