我尝试使用boost base64编码器,我找到了一个例子,但我得到了异常
typedef
transform_width< binary_from_base64<std::string::const_iterator>, 8, 6 > it_binary_t
Run Code Online (Sandbox Code Playgroud)
我用过的
std::string b64E(it_binary_t(Encrip.begin()), it_binary_t(Encrip.end()));
Run Code Online (Sandbox Code Playgroud)
我知道了
agentid_coder.exe中0x75b1b9bc处于未处理的异常:Microsoft C++异常:内存位置0x0046ed94处的boost :: archive :: iterators :: dataflow_exception ..
我发现这个解决方法,但我得到了相同的结果
string dec(
it_binary_t(Encrip.begin()),
it_binary_t(Encrip.begin() + Encrip.length() - 1)
);
Run Code Online (Sandbox Code Playgroud)
我正在使用MSVS2008并提升1.38
我在这里使用 boost gzip 示例代码。我正在尝试压缩一个简单的字符串测试,并期望压缩字符串H4sIAAAAAAAACitJLS4BAAx+f9gEAAAA如该在线压缩器所示
static std::string compress(const std::string& data)
{
namespace bio = boost::iostreams;
std::stringstream compressed;
std::stringstream origin(data);
bio::filtering_streambuf<bio::input> out;
out.push(bio::gzip_compressor(bio::gzip_params(bio::gzip::best_compression)));
out.push(origin);
bio::copy(out, compressed);
return compressed.str();
}
int main(int argc, char* argv[]){
std::cout << compress("text") << std::endl;
// prints out garabage
return 0;
}
Run Code Online (Sandbox Code Playgroud)
然而,当我打印出转换结果时,我得到了像+I-这样的垃圾值。〜
我知道这是一个有效的转换,因为解压值返回正确的字符串。但是我需要字符串的格式是人类可读的,即H4sIAAAAAAAACitJLS4BAAx+f9gEAAAA。
如何修改代码以输出人类可读的文本?
谢谢
动机
垃圾格式与我将通过其发送压缩文本的 JSON 库不兼容。