X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/4ca973967a5199ef46f425b8bc552fb19d433aba..8244507f687f59a6493948cc4482ee19f82e66c5:/src/common/convauto.cpp diff --git a/src/common/convauto.cpp b/src/common/convauto.cpp index c684613f4c..756e81c233 100644 --- a/src/common/convauto.cpp +++ b/src/common/convauto.cpp @@ -23,8 +23,6 @@ #pragma hdrstop #endif -#if wxUSE_WCHAR_T - #ifndef WX_PRECOMP #include "wx/wx.h" #endif //WX_PRECOMP @@ -107,11 +105,13 @@ wxConvAuto::BOMType wxConvAuto::DetectBOM(const char *src, size_t srcLen) if ( src[0] == '\x00' && src[1] == '\x00' ) { - // this could only be UTF-32BE - if ( srcLen == 3 && src[2] == '\xFE' ) - return BOM_Unknown; - } + // this could only be UTF-32BE, check that the data we have so + // far allows for it + if ( srcLen == 3 && src[2] != '\xFE' ) + return BOM_None; + return BOM_Unknown; + } break; default: @@ -229,7 +229,7 @@ void wxConvAuto::SkipBOM(const char **src, size_t *len) const bool wxConvAuto::InitFromInput(const char *src, size_t len) { - m_bomType = DetectBOM(src, len); + m_bomType = DetectBOM(src, len == wxNO_LEN ? strlen(src) : len); if ( m_bomType == BOM_Unknown ) return false; @@ -316,5 +316,3 @@ wxConvAuto::FromWChar(char *dst, size_t dstLen, return m_conv->FromWChar(dst, dstLen, src, srcLen); } - -#endif // wxUSE_WCHAR_T