本文整理汇总了C++中ustring::data方法的典型用法代码示例。如果您正苦于以下问题:C++ ustring::data方法的具体用法?C++ ustring::data怎么用?C++ ustring::data使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ustring
的用法示例。
在下文中一共展示了ustring::data方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: sizeof
void CGlobalRecords::wide2str16(const ustring& str1, u16string& str2)
{
size_t resultSize, inbytesleft, outbytesleft;
const uint8_t *inbuf;
iconv_t cd;
unsigned16_t *outbuf, *origOutbuf = NULL;
cd = iconv_open(UCS_2_INTERNAL, iconv_code.c_str());
// user may have changed the conversion since the workbook was opened
XL_ASSERT(!(cd == (iconv_t)(-1)));
if(cd != (iconv_t)(-1)) {
inbytesleft = str1.size() * sizeof(unichar_t);
outbytesleft = str1.size() * sizeof(unsigned16_t);
inbuf = (uint8_t *)str1.data();
origOutbuf = (unsigned16_t *)calloc(outbytesleft, 1);
outbuf = origOutbuf;
resultSize = iconv(cd, (char **)&inbuf, &inbytesleft, (char **)&outbuf, &outbytesleft);
iconv_close(cd);
} else {
resultSize = (size_t)-1;
}
if(resultSize == (size_t)-1) {
str2 = convFail;
} else {
str2.assign(origOutbuf, (size_t)(outbuf - origOutbuf));
}
free((void *)origOutbuf);
}
示例2: filter
ustring
b64_decode (const ustring &message)
{
bool succeeded = false;
auto_BIO mem (BIO_new (BIO_s_mem ()));
auto_BIO filter (BIO_new (BIO_f_base64()));
ustring rv;
BIO_set_flags(((BIO *) filter), BIO_FLAGS_BASE64_NO_NL);
BIO_push (filter, mem);
if ((BIO_write (mem,
message.data (),
message.size ()) >= 0)
&&
(1 == BIO_flush (mem)))
{
const unsigned int Length = BIO_pending (filter);
{
unsigned char *tmp_buf = (unsigned char *) VHTI_alloc (Length);
const int nread = BIO_read(filter, tmp_buf, Length);
if (nread >= 0)
{
succeeded = true;
rv.assign (tmp_buf, nread);
}
free (tmp_buf);
}
}
if (!succeeded)
throw SSL_ERROR;
return rv;
}
示例3: convert
bool IConvert::convert(const ustring& from,string& to) {
assert(!from.empty());
size_t insize = 0;
size_t outsize = 0;
iconv(m_iconv_from_unicode, NULL, &insize, NULL, &outsize);
insize = from.size() * sizeof(uchar_t);
outsize = BUFFER_SIZE;
size_t ret;
char* psrc = (char*)from.data();
char* pdest = m_buffer;
ret = iconv(m_iconv_from_unicode, &psrc, &insize, &pdest, &outsize);
if (ret == (size_t)(-1))
return false;
else {
to.assign(m_buffer,pdest);
//to.assign(m_buffer,(BUFFER_SIZE - outsize)/sizeof(char));
return true;
}
}