mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
UTF8
- Added UTF8 string width calculation.
This commit is contained in:
parent
8e536fa4a8
commit
551b4dbe90
3 changed files with 22 additions and 1 deletions
|
@ -32,7 +32,7 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
int main (int argc, char** argv)
|
||||
{
|
||||
UnitTest t (6);
|
||||
UnitTest t (10);
|
||||
|
||||
std::string ascii_text = "This is a test";
|
||||
std::string utf8_text = "más sábado miércoles";
|
||||
|
@ -57,6 +57,12 @@ int main (int argc, char** argv)
|
|||
t.is (utf8_substr (ascii_text, 0, 2), "Th", "ASCII utf8_substr");
|
||||
t.is (utf8_substr (utf8_text, 0, 2), "má", "UTF8 utf8_substr");
|
||||
|
||||
// unsigned int utf8_width (const std::string&);
|
||||
t.is (utf8_width ("one"), 3, "utf8_width 'one' --> 3");
|
||||
t.is (utf8_width ("más sábado miércoles"), 20, "utf8_width 'más sábado miércoles' --> 20");
|
||||
t.is (utf8_width ("改变各种颜色"), 12, "utf8_width '改变各种颜色' --> 12");
|
||||
t.is (utf8_width ("改"), 2, "utf8_width '改' --> 2");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue