Skip to content

Commit

Permalink
pow fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
pruzko committed Feb 22, 2019
1 parent 92ccf0c commit 2bd9a12
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/utils/string.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ bool isNonasciiChar(unsigned char c) {
*/
std::string replaceChars(const std::string &str, bool (* predicate)(unsigned char)) {
std::stringstream result;
const std::size_t maxC = (2 << (sizeof(std::string::value_type) * CHAR_BIT)) - 1;
const std::size_t maxC = (2 << (sizeof(std::string::value_type) * CHAR_BIT - 1)) - 1;
for (const auto &c : str) {
if (predicate(c)) {
const auto val = numToStr<std::size_t>(c & maxC, std::hex);
Expand Down Expand Up @@ -436,7 +436,7 @@ std::string unicodeToAscii(const std::uint8_t *bytes, std::size_t nBytes)
}
else
{
const std::size_t maxC = (2 << (sizeof(std::string::value_type) * CHAR_BIT)) - 1;
const std::size_t maxC = (2 << (sizeof(std::string::value_type) * CHAR_BIT - 1)) - 1;
const auto val1 = numToStr<std::size_t>(bytes[i] & maxC, std::hex);
const auto val2 = numToStr<std::size_t>(bytes[i + 1] & maxC, std::hex);
result << "\\x" << std::setw(2) << std::setfill('0') << val1;
Expand Down

0 comments on commit 2bd9a12

Please sign in to comment.