本文整理汇总了C++中Codec::reset方法的典型用法代码示例。如果您正苦于以下问题:C++ Codec::reset方法的具体用法?C++ Codec::reset怎么用?C++ Codec::reset使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Codec
的用法示例。
在下文中一共展示了Codec::reset方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
//.........这里部分代码省略.........
// call our charset guesser.
(void)c->toUnicode( body );
if ( !c->valid() )
specified = false;
// Not pretty.
}
}
if ( !c )
c = new AsciiCodec;
bp->d->hasText = true;
bp->d->text = c->toUnicode( body.crlf() );
if ( c->name() == "GB2312" || c->name() == "ISO-2022-JP" ||
c->name() == "KS_C_5601-1987" ) {
// undefined code point usage in GB2312 spam is much too
// common. (GB2312 spam is much too common, but that's
// another matter.) Gb2312Codec turns all undefined code
// points into U+FFFD, so here, we can take the unicode
// form and say it's the canonical form. when a client
// later reads the message, it gets the text in unicode,
// including U+FFFD.
bool bad = !c->valid();
// the header may contain some unencoded gb2312. we bang
// it by hand, ignoring errors.
List<HeaderField>::Iterator hf( h->fields() );
while ( hf ) {
if ( !hf->valid() &&
hf->type() == HeaderField::Subject ) {
// is it right to bang only Subject?
c->reset();
hf->setValue( c->toUnicode( hf->unparsedValue() ) );
}
++hf;
}
// if the body was bad, we prefer the (unicode) in
// bp->d->text and pretend it arrived as UTF-8:
if ( bad ) {
c = new Utf8Codec;
body = c->fromUnicode( bp->d->text );
}
}
if ( ( !specified && ( !c->wellformed() ||
ct->subtype() == "html" ) ) ||
( specified && ( !c->valid() ) ) ) {
Codec * g = 0;
if ( ct->subtype() == "html" )
g = guessHtmlCodec( body );
else
g = guessTextCodec( body );
UString guessed;
if ( g )
guessed = g->toUnicode( body.crlf() );
if ( !g ) {
// if we couldn't guess anything, keep what we had if
// it's valid or explicitly specified, else use
// unknown-8bit.
if ( !specified && !c->valid() ) {
c = new Unknown8BitCodec;
bp->d->text = c->toUnicode( body.crlf() );
}