increase buf to hold trailing '\0' + better names
This commit is contained in:
@@ -14,14 +14,14 @@ std::string uppercase(const std::string& str)
|
||||
boost::u8_to_u32_iterator<std::string::const_iterator> itr(str.begin());
|
||||
boost::u8_to_u32_iterator<std::string::const_iterator> end(str.end());
|
||||
std::string output;
|
||||
char buf[4];
|
||||
char buf[5];
|
||||
for (; itr!=end; ++itr)
|
||||
{
|
||||
char const* up = nu_toupper(*itr);
|
||||
if (up != 0) output.append(up);
|
||||
else
|
||||
{
|
||||
std::memset(buf, 0, 4);
|
||||
std::memset(buf, 0, 5);
|
||||
nu_utf8_write(*itr, buf);
|
||||
output.append(buf);
|
||||
}
|
||||
@@ -34,14 +34,14 @@ std::string lowercase(const std::string& str)
|
||||
boost::u8_to_u32_iterator<std::string::const_iterator> itr(str.begin());
|
||||
boost::u8_to_u32_iterator<std::string::const_iterator> end(str.end());
|
||||
std::string output;
|
||||
char buf[4];
|
||||
char buf[5];
|
||||
for (; itr!=end; ++itr)
|
||||
{
|
||||
char const* up = nu_tolower(*itr);
|
||||
if (up != 0) output.append(up);
|
||||
char const* lo = nu_tolower(*itr);
|
||||
if (lo != 0) output.append(lo);
|
||||
else
|
||||
{
|
||||
std::memset(buf, 0, 4);
|
||||
std::memset(buf, 0, 5);
|
||||
nu_utf8_write(*itr, buf);
|
||||
output.append(buf);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user