FTXUI  5.0.0
C++ functional terminal UI.
string.hpp
Go to the documentation of this file.
1// Copyright 2020 Arthur Sonzogni. All rights reserved.
2// Use of this source code is governed by the MIT license that can be found in
3// the LICENSE file.
4#ifndef FTXUI_SCREEN_STRING_HPP
5#define FTXUI_SCREEN_STRING_HPP
6
7#include <stddef.h> // for size_t
8#include <cstdint> // for uint8_t
9#include <string> // for string, wstring, to_string
10#include <vector> // for vector
11
12namespace ftxui {
13std::string to_string(const std::wstring& s);
14std::wstring to_wstring(const std::string& s);
15
16template <typename T>
17std::wstring to_wstring(T s) {
18 return to_wstring(std::to_string(s));
19}
20
21int string_width(const std::string&);
22
23// Split the string into a its glyphs. An empty one is inserted ater fullwidth
24// ones.
25std::vector<std::string> Utf8ToGlyphs(const std::string& input);
26
27// Map every cells drawn by |input| to their corresponding Glyphs. Half-size
28// Glyphs takes one cell, full-size Glyphs take two cells.
29std::vector<int> CellToGlyphIndex(const std::string& input);
30
31} // namespace ftxui
32
34
35#endif /* end of include guard: FTXUI_SCREEN_STRING_HPP */
std::vector< std::string > Utf8ToGlyphs(const std::string &input)
Definition: string.cpp:1356
int string_width(const std::string &)
Definition: string.cpp:1329
std::wstring to_wstring(const std::string &s)
Convert a std::wstring into a UTF8 std::string.
Definition: string.cpp:1637
std::string to_string(const std::wstring &s)
Convert a UTF8 std::string into a std::wstring.
Definition: string.cpp:1565
std::vector< int > CellToGlyphIndex(const std::string &input)
Definition: string.cpp:1464