This commit is contained in:
Eduardo Bart
2012-10-24 18:03:15 -02:00
parent c7890e7a49
commit 8bb115d6d4
9 changed files with 54 additions and 51 deletions

View File

@@ -67,9 +67,9 @@ uint64_t hex_to_dec(const std::string& str)
return num;
}
std::string utf8_to_latin1(uchar *utf8)
std::string utf8_to_latin1(const std::string& src)
{
auto utf8CharToLatin1 = [](uchar *utf8, int *read) -> char {
auto utf8CharToLatin1 = [](const uchar *utf8, int *read) -> char {
char c = '?';
uchar opt1 = utf8[0];
*read = 1;
@@ -89,10 +89,10 @@ std::string utf8_to_latin1(uchar *utf8)
};
std::string out;
int len = strlen((char*)utf8);
int len = src.length();
for(int i=0; i<len;) {
int read = 0;
uchar *utf8char = &utf8[i];
uchar *utf8char = (uchar*)&src[i];
out += utf8CharToLatin1(utf8char, &read);
i += read;
}

View File

@@ -42,7 +42,7 @@ std::string date_time_string();
std::string dec_to_hex(uint64_t num);
uint64_t hex_to_dec(const std::string& str);
std::string utf8_to_latin1(uchar *utf8);
std::string utf8_to_latin1(const std::string& src);
void tolower(std::string& str);
void toupper(std::string& str);
void trim(std::string& str);