FifeGUI 0.3.0
A C++ GUI library designed for games.
utf8stringeditor.hpp
1// SPDX-License-Identifier: LGPL-2.1-or-later OR BSD-3-Clause
2// SPDX-FileCopyrightText: 2004 - 2008 Olof Naessén and Per Larsson
3// SPDX-FileCopyrightText: 2013 - 2026 Fifengine contributors
4
5#ifndef INCLUDE_FIFECHAN_UTF8STRINGEDITOR_HPP_
6#define INCLUDE_FIFECHAN_UTF8STRINGEDITOR_HPP_
7
8// Standard library includes
9#include <string>
10
11// Platform config include
12#include "fifechan/platform.hpp"
13
14namespace fcn
15{
16
25 class FIFEGUI_API UTF8StringEditor
26 {
27 public:
35 static int nextChar(std::string const & text, int byteOffset);
36
44 static int prevChar(std::string const & text, int byteOffset);
45
53 static int eraseChar(std::string& text, int byteOffset);
54
63 static int insertChar(std::string& text, int byteOffset, int ch);
64
72 static int countChars(std::string const & text, int byteOffset);
73
84 static int getOffset(std::string const & text, int charIndex);
85 };
86
87}; // namespace fcn
88
89#endif // INCLUDE_FIFECHAN_UTF8STRINGEDITOR_HPP_
Utility for editing and handling UTF-8 encoded strings.
static int insertChar(std::string &text, int byteOffset, int ch)
Insert a character at specified byte offset.
static int countChars(std::string const &text, int byteOffset)
Counts characters up to byteOffset.
static int eraseChar(std::string &text, int byteOffset)
Erase character at specified byte offset.
static int getOffset(std::string const &text, int charIndex)
Gets byte offset for character index.
static int nextChar(std::string const &text, int byteOffset)
Returns byte offset of the next character.
static int prevChar(std::string const &text, int byteOffset)
Returns byte offset of the previous character.
Used replacement tokens by configure_file():