Utils::TextFileFormat Class
class Utils::TextFileFormatTextFileFormat クラスは、テキストファイルの形式を定義し、自動検出機能を提供します。詳細...
| Header: | #include <TextFileFormat> |
パブリック関数
| bool | decode(const QByteArray &data, QString *target) const |
| void | detectFromData(const QByteArray &data) |
| Utils::TextFileFormat::ReadResult | readFile(const Utils::FilePath &filePath, const Utils::TextEncoding &fallbackEncoding) |
| Utils::Result<> | writeFile(const Utils::FilePath &filePath, QString plainText) const |
静的パブリックメンバー
| QByteArray | decodingErrorSample(const QByteArray &data) |
詳細な説明
このフォーマットは以下で構成されます。
- コーデックの名前で表されるエンコーディング
- UTF-8 バイト順マーカー (BOM) の有無
- 改行の保存規則
また、このクラスは、テキストファイルを読み込んで文字列または文字列リストとして返したり、ファイルに書き出したりするための便利な関数も提供しています。
メンバ関数のドキュメント
bool TextFileFormat::decode(const QByteArray &data, QString *target) const
data をデコードして文字列(target )として返します。
[static] QByteArray TextFileFormat::decodingErrorSample(const QByteArray &data)
data で指定された、エンコーディングエラーの表示に適したテキストを返します。
void TextFileFormat::detectFromData(const QByteArray &data)
テキストの形式を検出しますdata 。
Utils::TextFileFormat::ReadResult TextFileFormat::readFile(const Utils::FilePath &filePath, const Utils::TextEncoding &fallbackEncoding)
filePath からテキストファイルを読み込み、文字列に変換します。ファイルの内容から読み取ったBOMに基づいて、使用するコーデックを検出します。設定されていない場合は、fallbackEncoding を使用します。フォールバックが設定されていない場合は、ロケールに設定されているテキストエンコーディングを使用します。
デコードがエラーなく実行できたかどうかを返します。エラーが発生した場合は、デコードエラーのサンプルとともにそのエラーが返されます。
Utils::Result<> TextFileFormat::writeFile(const Utils::FilePath &filePath, QString plainText) const
filePath にテキストファイルを出力し、plainText に文字列として格納します。
デコードがエラーなく行えたかどうかを返します。
Copyright © The Qt Company Ltd. and other contributors. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.