X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Flibpspp%2Fstr.c;fp=src%2Flibpspp%2Fstr.c;h=b40cb4b4ab8f07ac662965e70ae88adebfea90d0;hb=61cb03a73ff9f5d38e9728d4bf5a449212d3acdc;hp=86e7fd9199a5b9e22fba9fa2ac2eec4e9e7ff1c7;hpb=51acdebd6747816b6f955634e1bfcc9c8071b56d;p=pspp diff --git a/src/libpspp/str.c b/src/libpspp/str.c index 86e7fd9199..b40cb4b4ab 100644 --- a/src/libpspp/str.c +++ b/src/libpspp/str.c @@ -26,6 +26,7 @@ #include #include "libpspp/cast.h" +#include "libpspp/i18n.h" #include "libpspp/message.h" #include "libpspp/pool.h" @@ -928,6 +929,22 @@ ss_at_mblen (struct substring s, size_t ofs) else return 0; } + +size_t +ss_utf8_count_columns (struct substring s) +{ + return utf8_count_columns (s.string, s.length); +} + +/* Returns a substring of S starting at 0-based display column START and + running for N display columns. */ +struct substring +ss_utf8_columns (struct substring s, size_t start, size_t n) +{ + ss_advance (&s, utf8_columns_to_bytes (s.string, s.length, start)); + s.length = utf8_columns_to_bytes (s.string, s.length, n); + return s; +} /* Initializes ST as an empty string. */ void