Merge branch 'convauto_getencoding' of https://github.com/pavel-t/wxWidgets
Add wxConvAuto::GetEncoding(), other improvements and bug fixes. See https://github.com/wxWidgets/wxWidgets/pull/2072
This commit is contained in:
@@ -78,6 +78,8 @@ public:
|
||||
|
||||
virtual size_t GetMBNulLen() const wxOVERRIDE { return m_conv->GetMBNulLen(); }
|
||||
|
||||
virtual bool IsUTF8() const wxOVERRIDE { return m_conv && m_conv->IsUTF8(); }
|
||||
|
||||
virtual wxMBConv *Clone() const wxOVERRIDE { return new wxConvAuto(*this); }
|
||||
|
||||
// return the BOM type of this buffer
|
||||
@@ -91,6 +93,14 @@ public:
|
||||
return m_bomType;
|
||||
}
|
||||
|
||||
wxFontEncoding GetEncoding() const;
|
||||
|
||||
// Return true if the fall-back encoding is used
|
||||
bool IsUsingFallbackEncoding() const
|
||||
{
|
||||
return m_ownsConv && m_bomType == wxBOM_None;
|
||||
}
|
||||
|
||||
private:
|
||||
// common part of all ctors
|
||||
void Init()
|
||||
|
16
include/wx/private/unicode.h
Normal file
16
include/wx/private/unicode.h
Normal file
@@ -0,0 +1,16 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/private/unicode.h
|
||||
// Purpose: Unicode private declsrations
|
||||
// Author: Pavel Tyunin
|
||||
// Created: 2020-10-06
|
||||
// Copyright: (c) 2020 Pavel Tyunin
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_PRIVATE_UNICODEH__
|
||||
#define _WX_PRIVATE_UNICODEH__
|
||||
|
||||
// this table gives the length of the UTF-8 encoding from its first character:
|
||||
extern const unsigned char tableUtf8Lengths[256];
|
||||
|
||||
#endif // _WX_PRIVATE_UNICODEH__
|
@@ -94,15 +94,15 @@ struct WXDLLIMPEXP_BASE wxStringOperationsUtf8
|
||||
return (c <= 0x7F) || (c >= 0xC2 && c <= 0xF4);
|
||||
}
|
||||
|
||||
// table of offsets to skip forward when iterating over UTF-8 sequence
|
||||
static const unsigned char ms_utf8IterTable[256];
|
||||
// returns offset to skip forward when iterating over UTF-8 sequence
|
||||
static unsigned char GetUTF8IterOffset(unsigned char c);
|
||||
|
||||
|
||||
template<typename Iterator>
|
||||
static void IncIter(Iterator& i)
|
||||
{
|
||||
wxASSERT( IsValidUtf8LeadByte(*i) );
|
||||
i += ms_utf8IterTable[(unsigned char)*i];
|
||||
i += GetUTF8IterOffset(*i);
|
||||
}
|
||||
|
||||
template<typename Iterator>
|
||||
@@ -178,7 +178,7 @@ struct WXDLLIMPEXP_BASE wxStringOperationsUtf8
|
||||
static size_t GetUtf8CharLength(char c)
|
||||
{
|
||||
wxASSERT( IsValidUtf8LeadByte(c) );
|
||||
return ms_utf8IterTable[(unsigned char)c];
|
||||
return GetUTF8IterOffset(c);
|
||||
}
|
||||
|
||||
// decodes single UTF-8 character from UTF-8 string
|
||||
|
Reference in New Issue
Block a user