59 static const std::size_t
npos =
static_cast<std::size_t
>(-1);
68 const char *
p =
input.c_str();
69 std::size_t len =
input.length();
74 utf8::unchecked::utf8to32(
p,
p + len, std::back_inserter(
utf32chars));
87 std::size_t
width = 0;
88 foreach (
const boost::uint32_t& ch,
utf32chars) {
94 std::string
extract(
const std::string::size_type begin = 0,
95 const std::string::size_type len = 0)
const
104 utf8::unchecked::utf32to8
105 (
utf32chars.begin() +
static_cast<std::string::difference_type
>(begin),
106 utf32chars.begin() +
static_cast<std::string::difference_type
>(begin) +
107 static_cast<std::string::difference_type
>
115 std::size_t len)
const
132 if (pos +
w >= begin) {
133 head = std::min(pos +
w, begin + len) - begin;
136 }
else if (pos < begin + len) {
137 if (pos +
w > begin + len) {
138 tail = begin + len - pos;
141 if (pos +
w == begin + len) {
152 utf8::unchecked::utf32to8
162 std::size_t
find(
const boost::uint32_t
__s, std::size_t
__pos = 0)
const {
164 foreach (
const boost::uint32_t& ch,
utf32chars) {
175 const boost::uint32_t&
operator[](
const std::size_t index)
const {
181 const std::string& str,
187 if (
redden) out <<
"\033[31m";
189 if (
redden) out <<
"\033[0m";
199 if (
redden) out <<
"\033[31m";
201 if (
redden) out <<
"\033[0m";
#define TRACE_CTOR(cls, args)
void justify(std::ostream &out, const std::string &str, int width, bool right=false, bool redden=false)
int mk_wcwidth(boost::uint32_t ucs)
Abstract working with UTF-32 encoded Unicode strings.
std::size_t width() const
std::size_t length() const
std::string extract(const std::string::size_type begin=0, const std::string::size_type len=0) const
std::size_t find(const boost::uint32_t __s, std::size_t __pos=0) const
static const std::size_t npos
const boost::uint32_t & operator[](const std::size_t index) const
std::string extract_by_width(std::string::size_type begin, std::size_t len) const
std::vector< boost::uint32_t > utf32chars
unistring(const std::string &input)
boost::uint32_t & operator[](const std::size_t index)