KiCad PCB EDA Suite
|
An 8 bit string that is assuredly encoded in UTF8, and supplies special conversion support to and from wxString, to and from std::string, and has non-mutating iteration over Unicode characters. More...
#include <utf8.h>
Classes | |
class | uni_iter |
uni_iter is a non-mutating iterator that walks through unicode code points in the UTF8 encoded string. More... | |
Public Member Functions | |
UTF8 (const wxString &o) | |
UTF8 (const char *txt) | |
This is a constructor for which you could end up with non-UTF8 encoding, but that would be your fault. More... | |
UTF8 (const wchar_t *txt) | |
For use with _() function on wx 2.8. More... | |
UTF8 (const std::string &o) | |
UTF8 () | |
~UTF8 () | |
const char * | c_str () const |
bool | empty () const |
std::string::size_type | find (char c) const |
std::string::size_type | find (char c, size_t s) const |
void | clear () |
std::string::size_type | length () const |
std::string::size_type | size () const |
int | compare (const std::string &s) const |
bool | operator== (const UTF8 &rhs) const |
bool | operator== (const std::string &rhs) const |
bool | operator== (const char *s) const |
std::string::size_type | find_first_of (const std::string &str, std::string::size_type pos=0) const |
UTF8 & | operator+= (const UTF8 &str) |
UTF8 & | operator+= (char ch) |
UTF8 & | operator+= (const char *s) |
UTF8 & | operator+= (unsigned w_ch) |
Append a wide (unicode) char to the UTF8 string. More... | |
UTF8 & | operator= (const wxString &o) |
UTF8 & | operator= (const std::string &o) |
UTF8 & | operator= (const char *s) |
UTF8 & | operator= (char c) |
std::string | substr (size_t pos=0, size_t len=npos) const |
operator const std::string & () const | |
wxString | wx_str () const |
operator wxString () const | |
std::string::const_iterator | begin () const |
std::string::const_iterator | end () const |
uni_iter | ubegin () const |
Returns a uni_iter initialized to the start of "this" UTF8 byte sequence. More... | |
uni_iter | uend () const |
Return a uni_iter initialized to the end of "this" UTF8 byte sequence. More... | |
Static Public Member Functions | |
static int | uni_forward (const unsigned char *aSequence, unsigned *aResult=nullptr) |
Advance over a single UTF8 encoded multibyte character, capturing the Unicode character as it goes, and returning the number of bytes consumed. More... | |
Static Public Attributes | |
static constexpr std::string::size_type | npos = -1 |
Protected Attributes | |
std::string | m_s |
An 8 bit string that is assuredly encoded in UTF8, and supplies special conversion support to and from wxString, to and from std::string, and has non-mutating iteration over Unicode characters.
I've been careful to supply only conversion facilities and not try and duplicate wxString() with many member functions. There are multiple ways to create text into a std::string without the need of too many member functions:
Because this class uses no virtuals, it should be possible to cast any std::string into a UTF8 using this kind of cast: (UTF8 &) without construction or copying being the effect of the cast. Be sure the source std::string holds UTF8 encoded text before you do that.
|
inline |
This is a constructor for which you could end up with non-UTF8 encoding, but that would be your fault.
Definition at line 77 of file utf8.h.
References c_str(), and MAYBE_VERIFY_UTF8.
UTF8::UTF8 | ( | const wchar_t * | txt | ) |
|
inline |
Definition at line 87 of file utf8.h.
References c_str(), and MAYBE_VERIFY_UTF8.
|
inline |
|
inline |
Definition at line 102 of file utf8.h.
References m_s.
Referenced by PCB_IO_EAGLE::centerBoard(), DIALOG_EXCHANGE_FOOTPRINTS::DIALOG_EXCHANGE_FOOTPRINTS(), LIB_ID::Format(), DISPLAY_FOOTPRINTS_FRAME::GetFootprint(), PCB_IO_CADSTAR_ARCHIVE::LoadBoard(), DSN::SPECCTRA_DB::makeIMAGE(), FOOTPRINT_EDITOR_CONTROL::OpenWithTextEditor(), operator+=(), operator=(), DIALOG_EXCHANGE_FOOTPRINTS::processFootprint(), CVPCB_MAINFRAME::readNetListAndFpFiles(), PCB_EDIT_FRAME::RecreateBOMFileFromBoard(), CVPCB_MAINFRAME::refreshAfterSymbolSearch(), FOOTPRINT_EDIT_FRAME::UpdateTitle(), UTF8(), NETLIST_EXPORTER_SPICE::WriteDirectives(), and wx_str().
|
inline |
|
inline |
Definition at line 111 of file utf8.h.
References m_s.
Referenced by LIB_ID::compare(), and SCH_REFERENCE::CompareLibName().
|
inline |
Definition at line 103 of file utf8.h.
References m_s.
Referenced by FOOTPRINT_EDITOR_CONTROL::CreateFootprint(), SCH_SCREENS::GetLibNicknames(), SCH_SYMBOL::GetMsgPanelInfo(), SCH_SCREENS::HasNoFullyDefinedLibIds(), SYMBOL_EDITOR_CONTROL::Init(), FOOTPRINT_EDITOR_CONTROL::Init(), FOOTPRINT_EDITOR_CONTROL::NewFootprint(), PCB_EDIT_FRAME::OpenProjectFiles(), FOOTPRINT_EDITOR_CONTROL::PasteFootprint(), DIALOG_SYMBOL_REMAP::remapSymbolToLibTable(), FOOTPRINT_EDITOR_CONTROL::SaveAs(), LIB_TREE::setState(), SYMBOL_EDIT_FRAME::setupUIConditions(), FOOTPRINT_EDIT_FRAME::setupUIConditions(), and FOOTPRINT_EDIT_FRAME::UpdateTitle().
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Definition at line 109 of file utf8.h.
References m_s.
Referenced by PLACE_FILE_EXPORTER::GenPositionData().
|
inline |
|
inline |
Definition at line 130 of file utf8.h.
References c_str(), m_s, and MAYBE_VERIFY_UTF8.
|
inline |
Definition at line 137 of file utf8.h.
References c_str(), m_s, and MAYBE_VERIFY_UTF8.
Definition at line 123 of file utf8.h.
References c_str(), m_s, and MAYBE_VERIFY_UTF8.
UTF8 & UTF8::operator+= | ( | unsigned | w_ch | ) |
|
inline |
Definition at line 169 of file utf8.h.
References c_str(), m_s, and MAYBE_VERIFY_UTF8.
|
inline |
Definition at line 162 of file utf8.h.
References c_str(), m_s, and MAYBE_VERIFY_UTF8.
|
inline |
Definition at line 155 of file utf8.h.
References c_str(), m_s, and MAYBE_VERIFY_UTF8.
UTF8 & UTF8::operator= | ( | const wxString & | o | ) |
|
inline |
|
inline |
|
inline |
|
inline |
Definition at line 110 of file utf8.h.
References m_s.
Referenced by LIB_ID::Format(), LIB_TABLE::FormatOptions(), guessNickname(), PCB_EDIT_FRAME::LoadFootprints(), and setLibNickname().
|
inline |
Definition at line 178 of file utf8.h.
References m_s.
Referenced by operator+=(), and LIB_ID::Parse().
|
inline |
Returns a uni_iter initialized to the start of "this" UTF8 byte sequence.
Definition at line 279 of file utf8.h.
References m_s.
Referenced by KIGFX::OPENGL_GAL::computeBitmapTextSize(), and LIB_ID::FixIllegalChars().
|
inline |
Return a uni_iter initialized to the end of "this" UTF8 byte sequence.
Definition at line 287 of file utf8.h.
References m_s.
Referenced by KIGFX::OPENGL_GAL::computeBitmapTextSize(), and LIB_ID::FixIllegalChars().
|
static |
Advance over a single UTF8 encoded multibyte character, capturing the Unicode character as it goes, and returning the number of bytes consumed.
aSequence | is the UTF8 byte sequence, must be aligned on start of character. |
aResult | is where to put the unicode character, and may be NULL if no interest. |
Definition at line 67 of file utf8.cpp.
Referenced by IsUTF8(), UTF8::uni_iter::operator*(), UTF8::uni_iter::operator++(), and UTF8::uni_iter::operator->().
wxString UTF8::wx_str | ( | ) | const |
Definition at line 45 of file utf8.cpp.
References c_str().
Referenced by SCH_SCREEN::AddLibSymbol(), BOARD_NETLIST_UPDATER::addNewFootprint(), CVPCB_ASSOCIATION_TOOL::Associate(), CVPCB_MAINFRAME::AssociateFootprint(), BASIC_FOOTPRINT_INFO::BASIC_FOOTPRINT_INFO(), PANEL_FP_LIB_TABLE::browseLibrariesHandler(), SYMBOL_PREVIEW_WIDGET::DisplaySymbol(), PCBNEW_JOBS_HANDLER::doFpExportSvg(), SYMBOL_LIBS::FindLibSymbol(), RESCUE_SYMBOL_LIB_TABLE_CANDIDATE::FindRescues(), SYMBOL_LIB::FindSymbol(), PCB_IO_KICAD_SEXPR::FootprintSave(), SCH_IO_KICAD_SEXPR::Format(), FOOTPRINT_INFO_GENERATOR::GenerateHtml(), RESCUE_SYMBOL_LIB_TABLE_CANDIDATE::GetActionDescription(), LIB_ID::GetFullLibraryName(), SCH_IO_ALTIUM::getLibName(), SCH_IO_EAGLE::getLibName(), DISPLAY_FOOTPRINTS_FRAME::InitDisplay(), PCBNEW_JOBS_HANDLER::JobExportFpSvg(), PCB_IO_KICAD_LEGACY::loadFOOTPRINT(), PCB_EDIT_FRAME::LoadFootprints(), PCB_IO_KICAD_LEGACY::loadFP_SHAPE(), PCB_IO_KICAD_LEGACY::loadPAD(), SCH_IO_CADSTAR_ARCHIVE::LoadSchematicFile(), PANEL_SYMBOL_CHOOSER::populateFootprintSelector(), CVPCB_MAINFRAME::readNetListAndFpFiles(), DIALOG_SYMBOL_REMAP::remapSymbolsToLibTable(), DIALOG_SYMBOL_REMAP::remapSymbolToLibTable(), BOARD_NETLIST_UPDATER::replaceFootprint(), RESCUE_SYMBOL_LIB_TABLE_CANDIDATE::RESCUE_SYMBOL_LIB_TABLE_CANDIDATE(), SCH_IO_KICAD_SEXPR_LIB_CACHE::SaveSymbol(), SCH_IO_KICAD_SEXPR::saveSymbol(), SchGetLibSymbol(), PCB_BASE_FRAME::SelectFootprintFromLibrary(), DIALOG_EDIT_SYMBOLS_LIBID::setLibIdByBrowser(), setLibNickname(), FOOTPRINTS_LISTBOX::SetSelectedFootprint(), SYMBOL_VIEWER_FRAME::SetSelectedLibrary(), PANEL_SYMBOL_CHOOSER::showFootprintFor(), SYMBOL_CANDIDATE::SYMBOL_CANDIDATE(), BOARD_NETLIST_UPDATER::testConnectivity(), DIALOG_PLUGIN_OPTIONS::TransferDataFromWindow(), and BOARD_NETLIST_UPDATER::UpdateNetlist().
|
protected |
Definition at line 304 of file utf8.h.
Referenced by begin(), c_str(), clear(), compare(), empty(), end(), find(), find_first_of(), length(), operator const std::string &(), operator+=(), operator=(), operator==(), size(), substr(), ubegin(), uend(), and UTF8().
|
staticconstexpr |
Definition at line 151 of file utf8.h.
Referenced by LIB_ID::Parse().