Code::Blocks  SVN r11506
encodingdetector.h
Go to the documentation of this file.
1 /*
2  * This file is part of the Code::Blocks IDE and licensed under the GNU Lesser General Public License, version 3
3  * http://www.gnu.org/licenses/lgpl-3.0.html
4  */
5 
6 #ifndef ENCODINGDETECTOR_H
7 #define ENCODINGDETECTOR_H
8 
9 #include "settings.h"
10 #include "filemanager.h"
11 #include <wx/fontmap.h>
12 #include "nsUniversalDetector.h"
13 
14 class wxString;
15 
17 class DLLIMPORT EncodingDetector : public nsUniversalDetector
18 {
19  public:
20  EncodingDetector(const wxString& filename, bool useLog=true);
21  EncodingDetector(LoaderBase* fileLdr, bool useLog=true);
22  EncodingDetector(const wxByte* buffer, size_t size, bool useLog=true);
23  EncodingDetector(const EncodingDetector& rhs, bool useLog=true);
24  ~EncodingDetector() override;
25 
27  bool IsOK() const;
29  bool UsesBOM() const;
31  int GetBOMSizeInBytes() const;
33  wxFontEncoding GetFontEncoding() const;
34  wxString GetWxStr() const;
35  protected:
37  bool DetectEncoding(const wxString& filename, bool convert_to_wxstring = true);
38  bool DetectEncoding(const wxByte* buffer, size_t size, bool convert_to_wxstring = true);
39  bool DetectEncodingEx(const wxByte* buffer, size_t len);
40  void Report(const char* aCharset) override;
41 
42  bool m_IsOK;
43  bool m_UseBOM;
44  bool m_UseLog;
47  private:
48  bool ConvertToWxString(const wxByte* buffer, size_t size);
49 
52 };
53 
54 #endif // ENCODINGDETECTOR_H
wxFontEncoding m_Encoding
wxUint8 wxByte
wxFontEncoding
#define DLLIMPORT
Definition: settings.h:16
Try to detect the encoding of a file on disk.
wxString m_MozillaResult