mirror of
https://github.com/ton-blockchain/ton
synced 2025-03-09 15:40:10 +00:00
pow-testgiver support
This commit is contained in:
parent
dbde9c1c40
commit
f064b1047a
257 changed files with 6665 additions and 2608 deletions
|
@ -40,6 +40,15 @@ inline size_t utf8_length(Slice str) {
|
|||
return result;
|
||||
}
|
||||
|
||||
/// returns length of UTF-8 string in UTF-16 code units
|
||||
inline size_t utf8_utf16_length(Slice str) {
|
||||
size_t result = 0;
|
||||
for (auto c : str) {
|
||||
result += is_utf8_character_first_code_unit(c) + ((c & 0xf8) == 0xf0);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/// appends a Unicode character using UTF-8 encoding
|
||||
void append_utf8_character(string &str, uint32 ch);
|
||||
|
||||
|
@ -92,6 +101,9 @@ T utf8_utf16_truncate(T str, size_t length) {
|
|||
|
||||
template <class T>
|
||||
T utf8_substr(T str, size_t offset) {
|
||||
if (offset == 0) {
|
||||
return str;
|
||||
}
|
||||
auto offset_pos = utf8_truncate(str, offset).size();
|
||||
return str.substr(offset_pos);
|
||||
}
|
||||
|
@ -103,6 +115,9 @@ T utf8_substr(T str, size_t offset, size_t length) {
|
|||
|
||||
template <class T>
|
||||
T utf8_utf16_substr(T str, size_t offset) {
|
||||
if (offset == 0) {
|
||||
return str;
|
||||
}
|
||||
auto offset_pos = utf8_utf16_truncate(str, offset).size();
|
||||
return str.substr(offset_pos);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue