我有一個文件的Data-Url作爲std:string。 的base64編碼數據必須被解碼,然後被傳遞給該函數:C++ Data-Url as String to const byte *
open (const byte * data, long size)
所以第i個提取的編碼數據
size_t pos = dataurl.find_first_of(',');
std::string encoded = dataurl.substr(spos + 1);
然後,我使用此base64 decoder
std::string decoded = base64_decode(encoded);
那麼,我怎樣才能將類型字符串'解碼'爲字節*? 下面的代碼產生錯誤
open((byte *)decoded.c_str(), decoded.size() + 1);
//>>error: 'byte' was not declared in this scope
/編輯:所以有一個typedef
typedef uint8_t byte
的編碼數據是圖像!
確保包含定義'byte'的頭文件並使用['''codeddata()'](http://en.cppreference.com/w/cpp/string/basic_string/data)。 – Joe
聲明open函數在哪裏?它是一個班的成員嗎?命名空間的一部分? –
如果沒有一個,heck!它可能是'unsigned char'的typedef。 –