FIFE  6e1afdbeda11afe9ac53e6023a4be96ef88f1dc6
fcn::UTF8StringEditor Class Reference

UTF-8 string editor. More...

#include <utf8stringeditor.h>

+ Collaboration diagram for fcn::UTF8StringEditor:

Static Public Member Functions

static int nextChar (const std::string &text, int byteOffset)
 Returns byte offset of the next character. More...
 
static int prevChar (const std::string &text, int byteOffset)
 Returns byte offset of the previous character. More...
 
static int eraseChar (std::string &text, int byteOffset)
 Erase character at specified byte offset. More...
 
static int insertChar (std::string &text, int byteOffset, int ch)
 Insert a character at specified byte offset. More...
 
static int countChars (const std::string &text, int byteOffset)
 Counts characters up to byteOffset. More...
 
static int getOffset (const std::string &text, int charIndex)
 Gets byte offset for character index. More...
 

Detailed Description

UTF-8 string editor.

This is a helper class which allows to use UTF-8 strings in your application.

Author
Przemyslaw Grzywacz

Definition at line 45 of file utf8stringeditor.h.

Member Function Documentation

int fcn::UTF8StringEditor::countChars ( const std::string &  text,
int  byteOffset 
)
static

Counts characters up to byteOffset.

Parameters
textUTF-8 text to navigate.
byteOffsetByte offset inside the text.
Returns
Number of characters.

Definition at line 93 of file utf8stringeditor.cpp.

References utf8::distance().

int fcn::UTF8StringEditor::eraseChar ( std::string &  text,
int  byteOffset 
)
static

Erase character at specified byte offset.

Parameters
textUTF-8 text to modify.
byteOffsetByte offset of the character to erase.
Returns
New byte offset (is equal to byteOffset).

Definition at line 60 of file utf8stringeditor.cpp.

References utf8::next().

int fcn::UTF8StringEditor::getOffset ( const std::string &  text,
int  charIndex 
)
static

Gets byte offset for character index.

This method automaticly clips charIndex to be inside the string + EOF

Parameters
textUTF-8 text to navigate.
charIndexCharacter index to move to.
Returns
Byte offset of character at charIndex.

Definition at line 98 of file utf8stringeditor.cpp.

References utf8::next().

int fcn::UTF8StringEditor::insertChar ( std::string &  text,
int  byteOffset,
int  ch 
)
static

Insert a character at specified byte offset.

Parameters
textUTF-8 text to modify.
byteOffsetByte offset where character will be inserted.
chUnicode character to insert.
Returns
New byte offset (after the new character).

Definition at line 71 of file utf8stringeditor.cpp.

References utf8::append(), and utf8::next().

int fcn::UTF8StringEditor::nextChar ( const std::string &  text,
int  byteOffset 
)
static

Returns byte offset of the next character.

Parameters
textUTF-8 text to navigate.
byteOffsetByte offset of current character.
Returns
Byte offset of the next character.

Definition at line 38 of file utf8stringeditor.cpp.

References utf8::next().

int fcn::UTF8StringEditor::prevChar ( const std::string &  text,
int  byteOffset 
)
static

Returns byte offset of the previous character.

Parameters
textUTF-8 text to navigate.
byteOffsetByte offset of current character.
Returns
Byte offset of the previous character.

Definition at line 49 of file utf8stringeditor.cpp.

References utf8::prior().


The documentation for this class was generated from the following files: