我有一个代表图像的unsigned char数组,我想在网页中显示它。
我从ActiveX Control获取数组,我想在我的网页中使用JavaScript显示它,所以我必须将其转换为“base64 string”,所以我的问题是
如何在c ++中将unsigned char数组转换为base64字符串?
答案 0 :(得分:1)
例如:
unsigned char* array = <your data>;
int len = <number of bytes in "array">
int max_encoded_length = Base64encode_len(len);
char* encoded = new char[max_encoded_length];
int result = Base64encode(encoded, (const char *)array, len);
// encoded is now a null terminated b64 string
// "result" is the length of the string *including* the null terminator
// don't forget to invoke "delete [] encoded" when done