当前位置: 首页>>代码示例>>C++>>正文


C++ Book::encoding方法代码示例

本文整理汇总了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;
}
开发者ID:AnggriAone,项目名称:android-arabic-reader,代码行数:16,代码来源:RtfPlugin.cpp

示例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;
}
开发者ID:ALEXGUOQ,项目名称:FBReaderJ,代码行数:7,代码来源:OEBPlugin.cpp

示例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);
}
开发者ID:OpenInkpot-archive,项目名称:fbreader,代码行数:35,代码来源:FormatPlugin.cpp

示例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();
}
开发者ID:Brucechen13,项目名称:FBReaderJ,代码行数:8,代码来源:TxtPlugin.cpp

示例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;
}
开发者ID:euroelessar,项目名称:FBReader,代码行数:9,代码来源:PluckerPlugin.cpp

示例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());
	}
}
开发者ID:RavenB,项目名称:FBReaderJ,代码行数:11,代码来源:JavaNativeFormatPlugin.cpp

示例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);
	}
}
开发者ID:BinushBabu,项目名称:android-arabic-reader,代码行数:15,代码来源:JavaNativeFormatPlugin.cpp

示例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;
}
开发者ID:euroelessar,项目名称:FBReader,代码行数:15,代码来源:HtmlPlugin.cpp

示例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);
}
开发者ID:BinushBabu,项目名称:android-arabic-reader,代码行数:47,代码来源:JavaNativeFormatPlugin.cpp

示例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;
}
开发者ID:euroelessar,项目名称:FBReader,代码行数:43,代码来源:CHMPlugin.cpp

示例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);
}
开发者ID:yitoa,项目名称:YTReader,代码行数:23,代码来源:FormatPlugin.cpp

示例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;
}
开发者ID:ALEXGUOQ,项目名称:FBReaderJ,代码行数:23,代码来源:SimplePdbPlugin.cpp

示例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);
}
开发者ID:RavenB,项目名称:FBReaderJ,代码行数:36,代码来源:JavaNativeFormatPlugin.cpp

示例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;
}
开发者ID:04k,项目名称:FBReaderJ,代码行数:36,代码来源:FormatPlugin.cpp

示例15: RtfReader

RtfDescriptionReader::RtfDescriptionReader(Book &book) : RtfReader(book.encoding()), myBook(book) {
}
开发者ID:37Jayden,项目名称:bho,代码行数:2,代码来源:RtfDescriptionReader.cpp


注:本文中的Book::encoding方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。