Skip to content
This repository has been archived by the owner on Oct 10, 2019. It is now read-only.

Commit

Permalink
Overload utils::translit to accept const char* tocode
Browse files Browse the repository at this point in the history
  • Loading branch information
kobezda committed Sep 29, 2016
1 parent d41345f commit d0cea1b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions include/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ class utils {
static bool try_fs_lock(const std::string& lock_file, pid_t & pid);
static void remove_fs_lock(const std::string& lock_file);

static std::string translit(const char* tocode, const std::string& fromcode);
static std::string translit(const std::string& tocode, const std::string& fromcode);
static std::string convert_text(const std::string& text, const std::string& tocode, const std::string& fromcode);

Expand Down
4 changes: 2 additions & 2 deletions src/stflpp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ namespace newsbeuter {
*/

stfl::form::form(const std::string& text) : f(0) {
ipool = stfl_ipool_create(utils::translit(std::string(nl_langinfo(CODESET)), "WCHAR_T").c_str());
ipool = stfl_ipool_create(utils::translit(nl_langinfo(CODESET), "WCHAR_T").c_str());
if (!ipool) {
throw exception(errno);
}
Expand Down Expand Up @@ -83,7 +83,7 @@ static std::mutex quote_mtx;

std::string stfl::quote(const std::string& text) {
std::lock_guard<std::mutex> lock(quote_mtx);
stfl_ipool * ipool = stfl_ipool_create(utils::translit(std::string(nl_langinfo(CODESET)), "WCHAR_T").c_str());
stfl_ipool * ipool = stfl_ipool_create(utils::translit(nl_langinfo(CODESET), "WCHAR_T").c_str());
std::string retval = stfl_ipool_fromwc(ipool,stfl_quote(stfl_ipool_towc(ipool,text.c_str())));
stfl_ipool_destroy(ipool);
return retval;
Expand Down
5 changes: 5 additions & 0 deletions src/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,11 @@ bool utils::try_fs_lock(const std::string& lock_file, pid_t & pid) {
return false;
}

std::string utils::translit(const char* tocode, const std::string& fromcode)
{
return translit(std::string(tocode), fromcode);
}

std::string utils::translit(const std::string& tocode, const std::string& fromcode)
{
std::string tlit = "//TRANSLIT";
Expand Down

0 comments on commit d0cea1b

Please sign in to comment.