boost::urls::encode

返回百分号编码的字符串

概要

声明于 <boost/url/encode.hpp>

template<
    string_token::StringToken StringToken = string_token::return_string,
    grammar::CharSet CS>
StringToken::result_type
encode(
    core::string_view s,
    CS const& unreserved,
    encoding_opts opt = {},
    StringToken&& token = {}) noexcept;

描述

此函数使用给定的选项和字符集对字符串应用百分号编码,并在使用默认参数调用时将结果作为字符串返回。

示例

encoding_opts opt;
opt.space_as_plus = true;
std::string s = encode( "My Stuff", opt, pchars );

assert( s == "My+Stuff" );

异常安全性

分配调用可能会抛出异常。

返回值

字符串

参数

名称

描述

s

要编码的字符串。

unreserved

不进行百分号编码的字符集。

opt

编码的选项。如果省略此参数,则使用默认选项。

token

字符串令牌。

另请参阅