basic/string-util: add a convenience function to cescape mostly-ascii fields

It's not supposed to be the most efficient, but instead fast and simple to use.

I kept the logic in ellipsize_mem() to use unicode ellipsis even in non-unicode
locales. I'm not quite convinced things should be this way, especially that with
this patch it'd actually be simpler to always use "…" in unicode locale and "..."
otherwise, but Lennart wanted it this way for some reason.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek
2018-05-31 14:27:07 +02:00
parent b778252b4a
commit 8409f68858
3 changed files with 80 additions and 16 deletions
+1
View File
@@ -157,6 +157,7 @@ bool string_has_cc(const char *p, const char *ok) _pure_;
char *ellipsize_mem(const char *s, size_t old_length_bytes, size_t new_length_columns, unsigned percent);
char *ellipsize(const char *s, size_t length, unsigned percent);
char *cellescape(char *buf, size_t len, const char *s);
bool nulstr_contains(const char *nulstr, const char *needle);