コード例 #1
0
ファイル: sbuf.cpp プロジェクト: simsong/be13_api
/**
 * Read UTF-8 format code octets into string up to but not including \0.
 */
void sbuf_t::getUTF8(size_t i, std::string &utf8_string) const {
    // clear any residual value
    utf8_string = "";

    // read octets
    for (size_t off=i; off<bufsize; off++) {
        uint8_t octet = get8u(off);

        // stop before \0
        if (octet == 0) {
            // at \0
            break;
        }

        // accept the octet
        utf8_string.push_back(octet);
    }
}
コード例 #2
0
/**
 * Read UTF-8 format code octets into string up to but not including \0.
 */
void sbuf_t::getUTF8WithQuoting(size_t i, std::string &utf8_string) const {
    // clear any residual value
    utf8_string = "";

    // read octets
    for (size_t off=i; off<bufsize; off++) {
        uint8_t octet = get8u(off);

        // stop before \0
        if (octet == 0) {
            // at \0
            break;
        }

        // accept the octet
        utf8_string.push_back(octet);
    }

    // validate or escape utf8_string
    utf8_string = validateOrEscapeUTF8(utf8_string, true, true);
}