Skip to content

Commit

Permalink
Added brackets to binary operators
Browse files Browse the repository at this point in the history
  • Loading branch information
gentlegiantJGC committed Jul 15, 2024
1 parent ffb1255 commit 4fb276d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
18 changes: 9 additions & 9 deletions src/amulet_nbt/cpp/string_encoding/mutf8.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,24 +110,24 @@ namespace Amulet {
dst.push_back(c & 0b01111111);
}
else if (c <= 2047) {
dst.push_back(0b11000000 | 0b00011111 & (c >> 6));
dst.push_back(0b10000000 | 0b00111111 & c);
dst.push_back(0b11000000 | (0b00011111 & (c >> 6)));
dst.push_back(0b10000000 | (0b00111111 & c));
}
else if (c <= 65535) {
if ((c >= 0xD800) && (c <= 0xDFFF)) {
throw std::invalid_argument("code point at index " + std::to_string(index) + " cannot be encoded.");
}
dst.push_back(0b11100000 | 0b00001111 & (c >> 12));
dst.push_back(0b10000000 | 0b00111111 & (c >> 6));
dst.push_back(0b10000000 | 0b00111111 & c);
dst.push_back(0b11100000 | (0b00001111 & (c >> 12)));
dst.push_back(0b10000000 | (0b00111111 & (c >> 6)));
dst.push_back(0b10000000 | (0b00111111 & c));
}
else if (c <= 1114111) {
dst.push_back(0b11101101);
dst.push_back(0b10100000 | 0b00001111 & ((c >> 16) - 1));
dst.push_back(0b10000000 | 0b00111111 & (c >> 10));
dst.push_back(0b10100000 | (0b00001111 & ((c >> 16) - 1)));
dst.push_back(0b10000000 | (0b00111111 & (c >> 10)));
dst.push_back(0b11101101);
dst.push_back(0b10110000 | 0b00001111 & (c >> 6));
dst.push_back(0b10000000 | 0b00111111 & c);
dst.push_back(0b10110000 | (0b00001111 & (c >> 6)));
dst.push_back(0b10000000 | (0b00111111 & c));
}
else {
throw std::invalid_argument("Invalid code point at index " + std::to_string(index));
Expand Down
18 changes: 9 additions & 9 deletions src/amulet_nbt/cpp/string_encoding/utf8.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,8 @@ constexpr void _write_utf8(std::string &dst, const Amulet::CodePointVector& src)
dst.push_back(c & 0b01111111);
}
else if (c <= 2047) {
dst.push_back(0b11000000 | 0b00011111 & (c >> 6));
dst.push_back(0b10000000 | 0b00111111 & c);
dst.push_back(0b11000000 | (0b00011111 & (c >> 6)));
dst.push_back(0b10000000 | (0b00111111 & c));
}
else if (c <= 65535) {
if constexpr (escapeErrors){
Expand All @@ -203,15 +203,15 @@ constexpr void _write_utf8(std::string &dst, const Amulet::CodePointVector& src)
if ((c >= 0xD800) && (c <= 0xDFFF)){
throw std::invalid_argument("code point at index " + std::to_string(index) + " cannot be encoded.");
}
dst.push_back(0b11100000 | 0b00001111 & (c >> 12));
dst.push_back(0b10000000 | 0b00111111 & (c >> 6));
dst.push_back(0b10000000 | 0b00111111 & c);
dst.push_back(0b11100000 | (0b00001111 & (c >> 12)));
dst.push_back(0b10000000 | (0b00111111 & (c >> 6)));
dst.push_back(0b10000000 | (0b00111111 & c));
}
else if (c <= 1114111) {
dst.push_back(0b11110000 | 0b00000111 & (c >> 18));
dst.push_back(0b10000000 | 0b00111111 & (c >> 12));
dst.push_back(0b10000000 | 0b00111111 & (c >> 6));
dst.push_back(0b10000000 | 0b00111111 & c);
dst.push_back(0b11110000 | (0b00000111 & (c >> 18)));
dst.push_back(0b10000000 | (0b00111111 & (c >> 12)));
dst.push_back(0b10000000 | (0b00111111 & (c >> 6)));
dst.push_back(0b10000000 | (0b00111111 & c));
}
else {
throw std::invalid_argument("Invalid code point at index " + std::to_string(index));
Expand Down

0 comments on commit 4fb276d

Please sign in to comment.