Code::Blocks  SVN r11506
Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes | List of all members
EncodingDetector Class Reference

Try to detect the encoding of a file on disk. More...

#include <encodingdetector.h>

Inheritance diagram for EncodingDetector:
Collaboration diagram for EncodingDetector:

Public Member Functions

 EncodingDetector (const wxString &filename, bool useLog=true)
 
 EncodingDetector (LoaderBase *fileLdr, bool useLog=true)
 
 EncodingDetector (const wxByte *buffer, size_t size, bool useLog=true)
 
 EncodingDetector (const EncodingDetector &rhs, bool useLog=true)
 
 ~EncodingDetector () override
 
bool IsOK () const
 
bool UsesBOM () const
 
int GetBOMSizeInBytes () const
 
wxFontEncoding GetFontEncoding () const
 
wxString GetWxStr () const
 

Protected Member Functions

bool DetectEncoding (const wxString &filename, bool convert_to_wxstring=true)
 
bool DetectEncoding (const wxByte *buffer, size_t size, bool convert_to_wxstring=true)
 
bool DetectEncodingEx (const wxByte *buffer, size_t len)
 
void Report (const char *aCharset) override
 

Protected Attributes

bool m_IsOK
 
bool m_UseBOM
 
bool m_UseLog
 
int m_BOMSizeInBytes
 
wxFontEncoding m_Encoding
 

Private Member Functions

bool ConvertToWxString (const wxByte *buffer, size_t size)
 

Private Attributes

wxString m_MozillaResult
 
wxString m_ConvStr
 

Detailed Description

Try to detect the encoding of a file on disk.

Definition at line 17 of file encodingdetector.h.

Constructor & Destructor Documentation

◆ EncodingDetector() [1/4]

EncodingDetector::EncodingDetector ( const wxString filename,
bool  useLog = true 
)

◆ EncodingDetector() [2/4]

EncodingDetector::EncodingDetector ( LoaderBase fileLdr,
bool  useLog = true 
)

◆ EncodingDetector() [3/4]

EncodingDetector::EncodingDetector ( const wxByte buffer,
size_t  size,
bool  useLog = true 
)

◆ EncodingDetector() [4/4]

EncodingDetector::EncodingDetector ( const EncodingDetector rhs,
bool  useLog = true 
)

◆ ~EncodingDetector()

EncodingDetector::~EncodingDetector ( )
override

Definition at line 71 of file encodingdetector.cpp.

Member Function Documentation

◆ ConvertToWxString()

bool EncodingDetector::ConvertToWxString ( const wxByte buffer,
size_t  size 
)
private

◆ DetectEncoding() [1/2]

bool EncodingDetector::DetectEncoding ( const wxString filename,
bool  convert_to_wxstring = true 
)
protected
Returns
True if succeeded, false if not (e.g. file didn't exist).

Definition at line 113 of file encodingdetector.cpp.

References wxFile::Close(), wxFile::IsOpened(), wxFile::Length(), and wxFile::Read().

Referenced by EncodingDetector().

◆ DetectEncoding() [2/2]

bool EncodingDetector::DetectEncoding ( const wxByte buffer,
size_t  size,
bool  convert_to_wxstring = true 
)
protected

◆ DetectEncodingEx()

bool EncodingDetector::DetectEncodingEx ( const wxByte buffer,
size_t  len 
)
protected

◆ GetBOMSizeInBytes()

int EncodingDetector::GetBOMSizeInBytes ( ) const
Returns
The BOM size in bytes. Returns zero if no BOM.

Definition at line 98 of file encodingdetector.cpp.

References m_BOMSizeInBytes.

Referenced by cbEditorInternalData::cbEditorInternalData().

◆ GetFontEncoding()

wxFontEncoding EncodingDetector::GetFontEncoding ( ) const
Returns
The detected encoding. Currently ISO8859-1 is returned if no BOM is present.

Definition at line 103 of file encodingdetector.cpp.

References m_Encoding.

Referenced by cbEditorInternalData::cbEditorInternalData().

◆ GetWxStr()

wxString EncodingDetector::GetWxStr ( ) const

◆ IsOK()

bool EncodingDetector::IsOK ( ) const
Returns
True if file was read, false if not.

Definition at line 88 of file encodingdetector.cpp.

References m_IsOK.

Referenced by cbEditorInternalData::cbEditorInternalData(), FindReplace::FindInFiles(), CodeRefactoring::SearchInFiles(), and CodeRefactoring::VerifyResult().

◆ Report()

void EncodingDetector::Report ( const char *  aCharset)
overrideprotected

◆ UsesBOM()

bool EncodingDetector::UsesBOM ( ) const
Returns
True if the file contains a BOM (Byte Order Mark), false if not.

Definition at line 93 of file encodingdetector.cpp.

References m_UseBOM.

Referenced by cbEditorInternalData::cbEditorInternalData().

Member Data Documentation

◆ m_BOMSizeInBytes

int EncodingDetector::m_BOMSizeInBytes
protected

◆ m_ConvStr

wxString EncodingDetector::m_ConvStr
private

Definition at line 51 of file encodingdetector.h.

Referenced by ConvertToWxString(), and GetWxStr().

◆ m_Encoding

wxFontEncoding EncodingDetector::m_Encoding
protected

◆ m_IsOK

bool EncodingDetector::m_IsOK
protected

Definition at line 42 of file encodingdetector.h.

Referenced by EncodingDetector(), and IsOK().

◆ m_MozillaResult

wxString EncodingDetector::m_MozillaResult
private

Definition at line 50 of file encodingdetector.h.

Referenced by DetectEncoding(), and Report().

◆ m_UseBOM

bool EncodingDetector::m_UseBOM
protected

Definition at line 43 of file encodingdetector.h.

Referenced by DetectEncoding(), DetectEncodingEx(), and UsesBOM().

◆ m_UseLog

bool EncodingDetector::m_UseLog
protected

Definition at line 44 of file encodingdetector.h.

Referenced by ConvertToWxString(), DetectEncoding(), and Report().


The documentation for this class was generated from the following files: