- Timestamp:
- May 13, 2020 1:59:34 PM (5 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/com/string.h
r82968 r84287 661 661 662 662 663 /** @name BASE64 related methods 664 * @{ */ 665 /** 666 * Encodes the give data as BASE64. 667 * 668 * @returns S_OK or E_OUTOFMEMORY. 669 * @param pvData Pointer to the data to encode. 670 * @param cbData Number of bytes to encode. 671 * @param fLineBreaks Whether to add line breaks (true) or just encode it 672 * as a continuous string. 673 */ 674 HRESULT base64Encode(const void *pvData, size_t cbData, bool fLineBreaks = false); 675 /** @} */ 676 663 677 #if defined(VBOX_WITH_XPCOM) 664 678 /** -
trunk/src/VBox/Main/glue/string.cpp
r83785 r84287 18 18 #include "VBox/com/string.h" 19 19 20 #include <iprt/base64.h> 20 21 #include <iprt/err.h> 22 #include <iprt/log.h> 21 23 #include <iprt/path.h> 22 #include <iprt/log.h>23 24 #include <iprt/string.h> 24 25 #include <iprt/uni.h> … … 228 229 return ucLeft < ucRight ? -1 : 1; 229 230 } 231 } 232 233 HRESULT Bstr::base64Encode(const void *pvData, size_t cbData, bool fLineBreaks /*= false*/) 234 { 235 uint32_t const fFlags = fLineBreaks ? RTBASE64_FLAGS_EOL_LF : RTBASE64_FLAGS_NO_LINE_BREAKS; 236 size_t cwcEncoded = RTBase64EncodedUtf16LengthEx(cbData, fFlags); 237 HRESULT hrc = reserveNoThrow(cwcEncoded + 1); 238 if (SUCCEEDED(hrc)) 239 { 240 int vrc = RTBase64EncodeUtf16Ex(pvData, cbData, fFlags, mutableRaw(), cwcEncoded, &cwcEncoded); 241 AssertRCReturnStmt(vrc, setNull(), E_FAIL); 242 hrc = joltNoThrow(cwcEncoded); 243 } 244 return hrc; 230 245 } 231 246
Note:
See TracChangeset
for help on using the changeset viewer.