本文整理汇总了C++中Book::encoding方法的典型用法代码示例。如果您正苦于以下问题:C++ Book::encoding方法的具体用法?C++ Book::encoding怎么用?C++ Book::encoding使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Book
的用法示例。
在下文中一共展示了Book::encoding方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: readMetaInfo
bool RtfPlugin::readMetaInfo(Book &book) const {
if (!RtfDescriptionReader(book).readDocument(book.file())) {
return false;
}
if (book.encoding().empty()) {
book.setEncoding(ZLEncodingConverter::UTF8);
} else if (book.language().empty()) {
shared_ptr<ZLInputStream> stream = new RtfReaderStream(book.file(), 50000);
if (!stream.isNull()) {
detectLanguage(book, *stream, book.encoding());
}
}
return true;
}
示例2: readLanguageAndEncoding
bool OEBPlugin::readLanguageAndEncoding(Book &book) const {
if (book.language().empty()) {
shared_ptr<ZLInputStream> oebStream = new OEBTextStream(opfFile(book.file()));
detectLanguage(book, *oebStream, book.encoding());
}
return true;
}
示例3: detectEncodingAndLanguage
void FormatPlugin::detectEncodingAndLanguage(Book &book, ZLInputStream &stream) {
std::string language = book.language();
std::string encoding = book.encoding();
if (!encoding.empty() && !language.empty()) {
return;
}
PluginCollection &collection = PluginCollection::Instance();
if (language.empty()) {
language = collection.DefaultLanguageOption.value();
}
if (encoding.empty()) {
encoding = collection.DefaultEncodingOption.value();
}
if (collection.LanguageAutoDetectOption.value() && stream.open()) {
static const int BUFSIZE = 65536;
char *buffer = new char[BUFSIZE];
const size_t size = stream.read(buffer, BUFSIZE);
stream.close();
shared_ptr<ZLLanguageDetector::LanguageInfo> info =
ZLLanguageDetector().findInfo(buffer, size);
delete[] buffer;
if (!info.isNull()) {
if (!info->Language.empty()) {
language = info->Language;
}
encoding = info->Encoding;
if ((encoding == "US-ASCII") || (encoding == "ISO-8859-1")) {
encoding = "windows-1252";
}
}
}
book.setEncoding(encoding);
book.setLanguage(language);
}
示例4: readLanguageAndEncoding
bool TxtPlugin::readLanguageAndEncoding(Book &book) const {
shared_ptr<ZLInputStream> stream = book.file().inputStream();
if (stream.isNull()) {
return false;
}
detectEncodingAndLanguage(book, *stream);
return !book.encoding().empty();
}
示例5: readMetaInfo
bool PluckerPlugin::readMetaInfo(Book &book) const {
shared_ptr<ZLInputStream> stream = new PluckerTextStream(book.file());
detectEncodingAndLanguage(book, *stream);
if (book.encoding().empty()) {
return false;
}
return true;
}
示例6: fillLanguageAndEncoding
static void fillLanguageAndEncoding(JNIEnv* env, jobject javaBook, Book &book) {
JString language(env, book.language());
if (language.j() != 0) {
AndroidUtil::Method_Book_setLanguage->call(javaBook, language.j());
}
JString encoding(env, book.encoding());
if (encoding.j() != 0) {
AndroidUtil::Method_Book_setEncoding->call(javaBook, encoding.j());
}
}
示例7: fillLanguageAndEncoding
static void fillLanguageAndEncoding(JNIEnv* env, jobject javaBook, Book &book) {
jstring javaString;
javaString = AndroidUtil::createJavaString(env, book.language());
if (javaString != 0) {
AndroidUtil::Method_Book_setLanguage->call(javaBook, javaString);
env->DeleteLocalRef(javaString);
}
javaString = AndroidUtil::createJavaString(env, book.encoding());
if (javaString != 0) {
AndroidUtil::Method_Book_setEncoding->call(javaBook, javaString);
env->DeleteLocalRef(javaString);
}
}
示例8: readMetaInfo
bool HtmlPlugin::readMetaInfo(Book &book) const {
shared_ptr<ZLInputStream> stream = book.file().inputStream();
if (stream.isNull()) {
return false;
}
shared_ptr<ZLInputStream> htmlStream = new HtmlReaderStream(stream, 50000);
detectEncodingAndLanguage(book, *htmlStream);
if (book.encoding().empty()) {
return false;
}
HtmlDescriptionReader(book).readDocument(*stream);
return true;
}
示例9: fillMetaInfo
static void fillMetaInfo(JNIEnv* env, jobject javaBook, Book &book) {
jstring javaString;
javaString = AndroidUtil::createJavaString(env, book.title());
AndroidUtil::Method_Book_setTitle->call(javaBook, javaString);
env->DeleteLocalRef(javaString);
javaString = AndroidUtil::createJavaString(env, book.language());
if (javaString != 0) {
AndroidUtil::Method_Book_setLanguage->call(javaBook, javaString);
env->DeleteLocalRef(javaString);
}
javaString = AndroidUtil::createJavaString(env, book.encoding());
if (javaString != 0) {
AndroidUtil::Method_Book_setEncoding->call(javaBook, javaString);
env->DeleteLocalRef(javaString);
}
javaString = AndroidUtil::createJavaString(env, book.seriesTitle());
if (javaString != 0) {
jstring indexString = AndroidUtil::createJavaString(env, book.indexInSeries());
AndroidUtil::Method_Book_setSeriesInfo->call(javaBook, javaString, indexString);
if (indexString != 0) {
env->DeleteLocalRef(indexString);
}
env->DeleteLocalRef(javaString);
}
const AuthorList &authors = book.authors();
for (std::size_t i = 0; i < authors.size(); ++i) {
const Author &author = *authors[i];
javaString = env->NewStringUTF(author.name().c_str());
jstring key = env->NewStringUTF(author.sortKey().c_str());
AndroidUtil::Method_Book_addAuthor->call(javaBook, javaString, key);
env->DeleteLocalRef(key);
env->DeleteLocalRef(javaString);
}
const TagList &tags = book.tags();
for (std::size_t i = 0; i < tags.size(); ++i) {
const Tag &tag = *tags[i];
AndroidUtil::Method_Book_addTag->call(javaBook, tag.javaTag(env));
}
fillUids(env, javaBook, book);
}
示例10: readMetaInfo
bool CHMPlugin::readMetaInfo(Book &book) const {
const ZLFile &file = book.file();
shared_ptr<ZLInputStream> stream = file.inputStream();
if (stream.isNull() || !stream->open()) {
return false;
}
CHMFileInfo chmFile(file);
if (!chmFile.init(*stream)) {
return false;
}
CHMFileInfo::FileNames names = chmFile.sectionNames(stream);
if (names.empty()) {
return false;
}
/*
shared_ptr<ZLInputStream> entryStream = chmFile.entryStream(stream, names.Start);
if (entryStream.isNull()) {
entryStream = chmFile.entryStream(stream, names.Home);
}
if (entryStream.isNull()) {
entryStream = chmFile.entryStream(stream, names.TOC);
}
/ *
if (entryStream.isNull()) {
chmFile.entryStream(stream, names.Index);
}
* /
if (entryStream.isNull()) {
return false;
}
*/
CHMTextStream textStream(chmFile, stream);
detectEncodingAndLanguage(book, textStream);
if (book.encoding().empty()) {
return false;
}
return true;
}
示例11: detectLanguage
void FormatPlugin::detectLanguage(Book &book, ZLInputStream &stream) {
std::string language = book.language();
if (!language.empty()) {
return;
}
PluginCollection &collection = PluginCollection::Instance();
if (collection.isLanguageAutoDetectEnabled() && stream.open()) {
static const int BUFSIZE = 65536;
char *buffer = new char[BUFSIZE];
const size_t size = stream.read(buffer, BUFSIZE);
stream.close();
shared_ptr<ZLLanguageDetector::LanguageInfo> info =
ZLLanguageDetector().findInfoForEncoding(book.encoding(), buffer, size, -20000);
delete[] buffer;
if (!info.isNull()) {
if (!info->Language.empty()) {
language = info->Language;
}
}
}
book.setLanguage(language);
}
示例12: readMetainfo
bool SimplePdbPlugin::readMetainfo(Book &book) const {
const ZLFile &file = book.file();
shared_ptr<ZLInputStream> stream = createStream(file);
detectEncodingAndLanguage(book, *stream);
if (book.encoding().empty()) {
return false;
}
int readType = HtmlMetainfoReader::NONE;
if (book.title().empty()) {
readType |= HtmlMetainfoReader::TITLE;
}
if (book.authors().empty()) {
readType |= HtmlMetainfoReader::AUTHOR;
}
if (readType != HtmlMetainfoReader::NONE) {
//if ((readType != HtmlMetainfoReader::NONE) && TextFormatDetector().isHtml(*stream)) {
readType |= HtmlMetainfoReader::TAGS;
HtmlMetainfoReader metainfoReader(book, (HtmlMetainfoReader::ReadType)readType);
metainfoReader.readDocument(*stream);
}
return true;
}
示例13: fillMetaInfo
static void fillMetaInfo(JNIEnv* env, jobject javaBook, Book &book) {
JString title(env, book.title());
AndroidUtil::Method_Book_setTitle->call(javaBook, title.j());
JString language(env, book.language());
if (language.j() != 0) {
AndroidUtil::Method_Book_setLanguage->call(javaBook, language.j());
}
JString encoding(env, book.encoding());
if (encoding.j() != 0) {
AndroidUtil::Method_Book_setEncoding->call(javaBook, encoding.j());
}
JString seriesTitle(env, book.seriesTitle());
if (seriesTitle.j() != 0) {
JString indexString(env, book.indexInSeries());
AndroidUtil::Method_Book_setSeriesInfo->call(javaBook, seriesTitle.j(), indexString.j());
}
const AuthorList &authors = book.authors();
for (std::size_t i = 0; i < authors.size(); ++i) {
const Author &author = *authors[i];
JString name(env, author.name(), false);
JString key(env, author.sortKey(), false);
AndroidUtil::Method_Book_addAuthor->call(javaBook, name.j(), key.j());
}
const TagList &tags = book.tags();
for (std::size_t i = 0; i < tags.size(); ++i) {
const Tag &tag = *tags[i];
AndroidUtil::Method_Book_addTag->call(javaBook, tag.javaTag(env));
}
fillUids(env, javaBook, book);
}
示例14: detectEncodingAndLanguage
bool FormatPlugin::detectEncodingAndLanguage(Book &book, ZLInputStream &stream, bool force) {
std::string language = book.language();
std::string encoding = book.encoding();
if (!force && !encoding.empty()) {
return true;
}
bool detected = false;
PluginCollection &collection = PluginCollection::Instance();
if (encoding.empty()) {
encoding = ZLEncodingConverter::UTF8;
}
if (collection.isLanguageAutoDetectEnabled() && stream.open()) {
static const int BUFSIZE = 65536;
char *buffer = new char[BUFSIZE];
const std::size_t size = stream.read(buffer, BUFSIZE);
stream.close();
shared_ptr<ZLLanguageDetector::LanguageInfo> info = ZLLanguageDetector().findInfo(buffer, size);
delete[] buffer;
if (!info.isNull()) {
detected = true;
if (!info->Language.empty()) {
language = info->Language;
}
encoding = info->Encoding;
if (encoding == ZLEncodingConverter::ASCII || encoding == "iso-8859-1") {
encoding = "windows-1252";
}
}
}
book.setEncoding(encoding);
book.setLanguage(language);
return detected;
}
示例15: RtfReader
RtfDescriptionReader::RtfDescriptionReader(Book &book) : RtfReader(book.encoding()), myBook(book) {
}