diff options
author | Florent Le Coz <louiz@louiz.org> | 2014-04-28 19:44:09 +0200 |
---|---|---|
committer | Florent Le Coz <louiz@louiz.org> | 2014-04-28 19:44:09 +0200 |
commit | 594bac1e841588aef66efc208a295e08273aec32 (patch) | |
tree | 41ed18c2f4b9851e77f726ab51dfbc783a9e4a39 /src/utils/encoding.cpp | |
parent | c6059e5a215624e205cae401183f3a8bb1bf87d0 (diff) | |
download | biboumi-594bac1e841588aef66efc208a295e08273aec32.tar.gz biboumi-594bac1e841588aef66efc208a295e08273aec32.tar.bz2 biboumi-594bac1e841588aef66efc208a295e08273aec32.tar.xz biboumi-594bac1e841588aef66efc208a295e08273aec32.zip |
Remove binary.hpp and use the c++14 feature 0b
Diffstat (limited to 'src/utils/encoding.cpp')
-rw-r--r-- | src/utils/encoding.cpp | 45 |
1 files changed, 22 insertions, 23 deletions
diff --git a/src/utils/encoding.cpp b/src/utils/encoding.cpp index fa4958b..dc0101c 100644 --- a/src/utils/encoding.cpp +++ b/src/utils/encoding.cpp @@ -1,5 +1,4 @@ #include <utils/encoding.hpp> -#include <utils/binary.hpp> #include <utils/scopeguard.hpp> @@ -35,34 +34,34 @@ namespace utils while (*str) { // 4 bytes: 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx - if ((str[0] & 11111000_b) == 11110000_b) + if ((str[0] & 0b11111000) == 0b11110000) { if (!str[1] || !str[2] || !str[3] - || ((str[1] & 11000000_b) != 10000000_b) - || ((str[2] & 11000000_b) != 10000000_b) - || ((str[3] & 11000000_b) != 10000000_b)) + || ((str[1] & 0b11000000) != 0b10000000) + || ((str[2] & 0b11000000) != 0b10000000) + || ((str[3] & 0b11000000) != 0b10000000)) return false; str += 4; } // 3 bytes: 1110xxx 10xxxxxx 10xxxxxx - else if ((str[0] & 11110000_b) == 11100000_b) + else if ((str[0] & 0b11110000) == 0b11100000) { if (!str[1] || !str[2] - || ((str[1] & 11000000_b) != 10000000_b) - || ((str[2] & 11000000_b) != 10000000_b)) + || ((str[1] & 0b11000000) != 0b10000000) + || ((str[2] & 0b11000000) != 0b10000000)) return false; str += 3; } // 2 bytes: 110xxxxx 10xxxxxx - else if (((str[0]) & 11100000_b) == 11000000_b) + else if (((str[0]) & 0b11100000) == 0b11000000) { if (!str[1] || - ((str[1] & 11000000_b) != 10000000_b)) + ((str[1] & 0b11000000) != 0b10000000)) return false; str += 2; } // 1 byte: 0xxxxxxx - else if ((str[0] & 10000000_b) != 0) + else if ((str[0] & 0b10000000) != 0) return false; else str++; @@ -85,12 +84,12 @@ namespace utils while (*str) { // 4 bytes: 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx - if ((str[0] & 11111000_b) == 11110000_b) + if ((str[0] & 0b11111000) == 0b11110000) { - codepoint = ((str[0] & 00000111_b) << 18); - codepoint |= ((str[1] & 00111111_b) << 12); - codepoint |= ((str[2] & 00111111_b) << 6 ); - codepoint |= ((str[3] & 00111111_b) << 0 ); + codepoint = ((str[0] & 0b00000111) << 18); + codepoint |= ((str[1] & 0b00111111) << 12); + codepoint |= ((str[2] & 0b00111111) << 6 ); + codepoint |= ((str[3] & 0b00111111) << 0 ); if (codepoint.to_ulong() <= 0x10FFFF) { ::memcpy(r, str, 4); @@ -99,11 +98,11 @@ namespace utils str += 4; } // 3 bytes: 1110xxx 10xxxxxx 10xxxxxx - else if ((str[0] & 11110000_b) == 11100000_b) + else if ((str[0] & 0b11110000) == 0b11100000) { - codepoint = ((str[0] & 00001111_b) << 12); - codepoint |= ((str[1] & 00111111_b) << 6); - codepoint |= ((str[2] & 00111111_b) << 0 ); + codepoint = ((str[0] & 0b00001111) << 12); + codepoint |= ((str[1] & 0b00111111) << 6); + codepoint |= ((str[2] & 0b00111111) << 0 ); if (codepoint.to_ulong() <= 0xD7FF || (codepoint.to_ulong() >= 0xE000 && codepoint.to_ulong() <= 0xFFFD)) { @@ -113,7 +112,7 @@ namespace utils str += 3; } // 2 bytes: 110xxxxx 10xxxxxx - else if (((str[0]) & 11100000_b) == 11000000_b) + else if (((str[0]) & 0b11100000) == 0b11000000) { // All 2 bytes char are valid, don't even bother calculating // the codepoint @@ -122,9 +121,9 @@ namespace utils str += 2; } // 1 byte: 0xxxxxxx - else if ((str[0] & 10000000_b) == 0) + else if ((str[0] & 0b10000000) == 0) { - codepoint = ((str[0] & 01111111_b)); + codepoint = ((str[0] & 0b01111111)); if (codepoint.to_ulong() == 0x09 || codepoint.to_ulong() == 0x0A || codepoint.to_ulong() == 0x0D || |