Skip to content

Instantly share code, notes, and snippets.

View vinniefalco's full-sized avatar
🏠
Working from home

Vinnie Falco vinniefalco

🏠
Working from home
View GitHub Profile
namespace url {
class basic_value
{
char* s_;
protected:
virtual
char*
reserve(
// 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;
// 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;
utf8_counter&
operator=(char32_t cp) noexcept
{
if(cp < 0x80)
{
n += 1;
return;
}
if(cp < 0x800)
{
template<class InputIt>
static
std::size_t
encoded_size(
InputIt first,
InputIt last)
{
struct counter
{
std::size_t& n;
// 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) {
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
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
*/
struct pmeasure
{
std::size_t n = 0;
void
append(std::uint32_t) noexcept
{
++n;
}
struct pwriter
{
std::uint32_t* begin;
std::uint32_t* dest;
void
append(std::uint32_t cp) noexcept
{
*dest++ = cp;
}