This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace url { | |
class basic_value | |
{ | |
char* s_; | |
protected: | |
virtual | |
char* | |
reserve( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// return `true` if the hex | |
// word could be 0..255 if | |
// interpreted as decimal | |
bool | |
maybe_octet(long word) | |
{ | |
if(word > 0x255) | |
return false; | |
unsigned short d1 = | |
(word >> 8) & 0xf; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// return `true` if the hex | |
// word could be 0..255 if | |
// interpreted as decimal | |
bool | |
maybe_octet(long word) | |
{ | |
char dig[4]; | |
dig[0] = (word >> 12) & 0xff; | |
dig[1] = (word >> 8) & 0xff; | |
dig[2] = (word >> 4) & 0xff; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
utf8_counter& | |
operator=(char32_t cp) noexcept | |
{ | |
if(cp < 0x80) | |
{ | |
n += 1; | |
return; | |
} | |
if(cp < 0x800) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
template<class InputIt> | |
static | |
std::size_t | |
encoded_size( | |
InputIt first, | |
InputIt last) | |
{ | |
struct counter | |
{ | |
std::size_t& n; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Javascript code which works: | |
const basicToDigit = function(codePoint) { | |
if (codePoint - 0x30 < 0x0A) { | |
return codePoint - 0x16; | |
} | |
if (codePoint - 0x41 < 0x1A) { | |
return codePoint - 0x41; | |
} | |
if (codePoint - 0x61 < 0x1A) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
template<class F> | |
void | |
test_set(F const& f) | |
{ | |
f("bcher-kva", | |
{ 'b', 0xFC, 'c', 'h', 'e', 'r' }); | |
/* | |
(A) Arabic (Egyptian): | |
u+0644 u+064A u+0647 u+0645 u+0627 u+0628 u+062A u+0643 u+0644 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
template<class F> | |
void | |
test_set(F const& f) | |
{ | |
/* | |
(A) Arabic (Egyptian): | |
u+0644 u+064A u+0647 u+0645 u+0627 u+0628 u+062A u+0643 u+0644 | |
u+0645 u+0648 u+0634 u+0639 u+0631 u+0628 u+064A u+061F | |
Punycode: egbpdaj6bu4bxfgehfvwxn | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct pmeasure | |
{ | |
std::size_t n = 0; | |
void | |
append(std::uint32_t) noexcept | |
{ | |
++n; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct pwriter | |
{ | |
std::uint32_t* begin; | |
std::uint32_t* dest; | |
void | |
append(std::uint32_t cp) noexcept | |
{ | |
*dest++ = cp; | |
} |