예제 #1
0
std::pair<uint32_t, bool> unescapeNextUtf8(FwdIt& first, FwdIt last,
                                           uint32_t escapeChar = '\\')
{
    auto it = beginUtf8Fwd(first, last);
    auto result = String::unescapeNext(it, endUtf8Fwd(last, last),
                                       escapeChar);
    first = beginInternal(it);
    return result;
    // uint32_t ch = Unicode::Invalid;
    // if (nextCodePoint(ch, beg, end) != DecodeResult::Ok ||
    //                   ch != escapeChar ||
    //                   nextCodePoint(ch, beg, end) != DecodeResult::Ok)
    //     return std::make_pair(ch, false);

    // switch (ch)
    // {
    // case '0': ch = '\0'; break;
    // case 'a': ch = '\a'; break;
    // case 'b': ch = '\b'; break;
    // case 'f': ch = '\f'; break;
    // case 'n': ch = '\n'; break;
    // case 'r': ch = '\r'; break;
    // case 't': ch = '\t'; break;
    // case 'v': ch = '\v'; break;
    // case 'u': ch = fromHex(beg, end, 4); break;
    // case 'U': ch = fromHex(beg, end, 8); break;
    // case 'x': ch = fromHex(beg, end, 2); break;
    // default: break;
    // }

    // return std::make_pair(ch, true);
}
예제 #2
0
/**
 * parsing the url for all needed parameters
 * @param url String
 */
bool HTTPClient::begin(String url)
{
    _transportTraits.reset(nullptr);
    if (!beginInternal(url, "http")) {
        return false;
    }
    _transportTraits = TransportTraitsPtr(new TransportTraits());
    return true;
}
예제 #3
0
bool HTTPClient::begin(String url, String httpsFingerprint)
{
    _transportTraits.reset(nullptr);
    if (httpsFingerprint.length() == 0) {
        return false;
    }
    if (!beginInternal(url, "https")) {
        return false;
    }
    _transportTraits = TransportTraitsPtr(new TLSTraits(httpsFingerprint));
    DEBUG_HTTPCLIENT("[HTTP-Client][begin] httpsFingerprint: %s\n", httpsFingerprint.c_str());
    return true;
}