X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/4cb0e8d05cadea6be3a7bd93f1fea9a9e0df95f0..8e77fd8bca165aab9709649d79a7cbc6a172d4e1:/include/wx/convauto.h?ds=sidebyside diff --git a/include/wx/convauto.h b/include/wx/convauto.h index 3a2e2e4809..25019a55e5 100644 --- a/include/wx/convauto.h +++ b/include/wx/convauto.h @@ -14,12 +14,22 @@ #include "wx/strconv.h" #include "wx/fontenc.h" -#if wxUSE_WCHAR_T - // ---------------------------------------------------------------------------- // wxConvAuto: uses BOM to automatically detect input encoding // ---------------------------------------------------------------------------- +// All currently recognized BOM values. +enum wxBOM +{ + wxBOM_Unknown = -1, + wxBOM_None, + wxBOM_UTF32BE, + wxBOM_UTF32LE, + wxBOM_UTF16BE, + wxBOM_UTF16LE, + wxBOM_UTF8 +}; + class WXDLLIMPEXP_BASE wxConvAuto : public wxMBConv { public: @@ -71,29 +81,27 @@ public: virtual wxMBConv *Clone() const { return new wxConvAuto(*this); } -private: - // all currently recognized BOM values - enum BOMType - { - BOM_Unknown = -1, - BOM_None, - BOM_UTF32BE, - BOM_UTF32LE, - BOM_UTF16BE, - BOM_UTF16LE, - BOM_UTF8 - }; - // return the BOM type of this buffer - static BOMType DetectBOM(const char *src, size_t srcLen); + static wxBOM DetectBOM(const char *src, size_t srcLen); + // return the characters composing the given BOM. + static const char* GetBOMChars(wxBOM bomType, size_t* count); + + wxBOM GetBOM() const + { + return m_bomType; + } + +private: // common part of all ctors void Init() { - // no need to initialize m_bomType and m_consumedBOM here, this will be - // done when m_conv is created + // We don't initialize m_encDefault here as different ctors do it + // differently. m_conv = NULL; + m_bomType = wxBOM_Unknown; m_ownsConv = false; + m_consumedBOM = false; } // initialize m_conv with the UTF-8 conversion @@ -104,14 +112,14 @@ private: } // create the correct conversion object for the given BOM type - void InitFromBOM(BOMType bomType); + void InitFromBOM(wxBOM bomType); // create the correct conversion object for the BOM present in the - // beginning of the buffer; adjust the buffer to skip the BOM if found + // beginning of the buffer // // return false if the buffer is too short to allow us to determine if we // have BOM or not - bool InitFromInput(const char **src, size_t *len); + bool InitFromInput(const char *src, size_t len); // adjust src and len to skip over the BOM (identified by m_bomType) at the // start of the buffer @@ -130,7 +138,7 @@ private: wxFontEncoding m_encDefault; // our BOM type - BOMType m_bomType; + wxBOM m_bomType; // true if we allocated m_conv ourselves, false if we just use an existing // global conversion @@ -144,7 +152,5 @@ private: wxDECLARE_NO_ASSIGN_CLASS(wxConvAuto); }; -#endif // wxUSE_WCHAR_T - #endif // _WX_CONVAUTO_H_