X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/01a9232b5e06fc1e24cbd051661d37a46827379d..be19c556083cc197be55acbd05db76ec6dc2e0c4:/include/wx/convauto.h diff --git a/include/wx/convauto.h b/include/wx/convauto.h index 398888a788..bc514cea3b 100644 --- a/include/wx/convauto.h +++ b/include/wx/convauto.h @@ -14,8 +14,6 @@ #include "wx/strconv.h" #include "wx/fontenc.h" -#if wxUSE_WCHAR_T - // ---------------------------------------------------------------------------- // wxConvAuto: uses BOM to automatically detect input encoding // ---------------------------------------------------------------------------- @@ -26,7 +24,8 @@ public: // default ctor, the real conversion will be created on demand wxConvAuto(wxFontEncoding enc = wxFONTENCODING_DEFAULT) { - m_conv = NULL; // the rest will be initialized later + Init(); + m_encDefault = enc; } @@ -34,7 +33,8 @@ public: // deduced on first use wxConvAuto(const wxConvAuto& other) : wxMBConv() { - m_conv = NULL; + Init(); + m_encDefault = other.m_encDefault; } @@ -73,6 +73,7 @@ private: // all currently recognized BOM values enum BOMType { + BOM_Unknown = -1, BOM_None, BOM_UTF32BE, BOM_UTF32LE, @@ -84,6 +85,15 @@ private: // return the BOM type of this buffer static BOMType DetectBOM(const char *src, size_t srcLen); + // 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 + m_conv = NULL; + m_ownsConv = false; + } + // initialize m_conv with the UTF-8 conversion void InitWithUTF8() { @@ -95,8 +105,11 @@ private: void InitFromBOM(BOMType 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 - void InitFromInput(const char **src, size_t *len); + // 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); // adjust src and len to skip over the BOM (identified by m_bomType) at the // start of the buffer @@ -126,10 +139,8 @@ private: bool m_consumedBOM; - DECLARE_NO_ASSIGN_CLASS(wxConvAuto) + wxDECLARE_NO_ASSIGN_CLASS(wxConvAuto); }; -#endif // wxUSE_WCHAR_T - #endif // _WX_CONVAUTO_H_