Add wxConvAuto::GetEncoding()
This commit is contained in:
@@ -93,6 +93,8 @@ public:
|
|||||||
return m_bomType;
|
return m_bomType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wxFontEncoding GetEncoding() const;
|
||||||
|
|
||||||
// Return true if the fall-back encoding is used
|
// Return true if the fall-back encoding is used
|
||||||
bool IsFallbackEncoding() const
|
bool IsFallbackEncoding() const
|
||||||
{
|
{
|
||||||
|
@@ -146,6 +146,15 @@ public:
|
|||||||
*/
|
*/
|
||||||
wxBOM GetBOM() const;
|
wxBOM GetBOM() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Return the detected encoding
|
||||||
|
|
||||||
|
Returns @c wxFONTENCODING_MAX if called before the first use.
|
||||||
|
|
||||||
|
@since 3.1.5
|
||||||
|
*/
|
||||||
|
wxBOM GetEncoding() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Check if the fall-back encoding is used.
|
Check if the fall-back encoding is used.
|
||||||
|
|
||||||
|
@@ -351,3 +351,34 @@ wxConvAuto::FromWChar(char *dst, size_t dstLen,
|
|||||||
|
|
||||||
return m_conv->FromWChar(dst, dstLen, src, srcLen);
|
return m_conv->FromWChar(dst, dstLen, src, srcLen);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wxFontEncoding wxConvAuto::GetEncoding() const
|
||||||
|
{
|
||||||
|
switch ( m_bomType )
|
||||||
|
{
|
||||||
|
case wxBOM_UTF32BE:
|
||||||
|
return wxFONTENCODING_UTF32BE;
|
||||||
|
case wxBOM_UTF32LE:
|
||||||
|
return wxFONTENCODING_UTF32LE;
|
||||||
|
case wxBOM_UTF16BE:
|
||||||
|
return wxFONTENCODING_UTF16BE;
|
||||||
|
case wxBOM_UTF16LE:
|
||||||
|
return wxFONTENCODING_UTF16LE;
|
||||||
|
case wxBOM_UTF8:
|
||||||
|
return wxFONTENCODING_UTF8;
|
||||||
|
|
||||||
|
case wxBOM_Unknown:
|
||||||
|
case wxBOM_None:
|
||||||
|
if ( !m_conv )
|
||||||
|
return wxFONTENCODING_MAX;
|
||||||
|
else if ( !m_ownsConv )
|
||||||
|
return wxFONTENCODING_UTF8;
|
||||||
|
else if ( m_encDefault != wxFONTENCODING_DEFAULT )
|
||||||
|
return m_encDefault;
|
||||||
|
else
|
||||||
|
return GetFallbackEncoding();
|
||||||
|
}
|
||||||
|
|
||||||
|
wxFAIL_MSG( "unknown BOM type" );
|
||||||
|
return wxFONTENCODING_MAX;
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user