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) |
상세 설명
이 형식은 다음으로 구성됩니다.
- 코덱 이름으로 표시되는 인코딩
- UTF8 바이트 순서 마커(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.