summaryrefslogtreecommitdiff
path: root/src/basic/string-util.c
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2016-09-12 20:09:36 +0100
committerSven Eden <yamakuzure@gmx.net>2017-07-05 08:50:53 +0200
commit2aa9a6ee147f5dab268d9546af3ef3749153dadd (patch)
tree0dba016f8679cb169feac54aa04c7f062d4fdd83 /src/basic/string-util.c
parent0b4e594c9274e03cd8ab03a17a449d2f98c8e260 (diff)
Always use unicode ellipsis when ellipsizing
We were already unconditionally using the unicode character when the input string was not pure ASCII, leading to different behaviour in depending on the input string. elogind[1]: Starting printit.service. python3[19962]: foooooooooooooooooooooooooooooooooooo…oooo python3[19964]: fooąęoooooooooooooooooooooooooooooooo…oooo python3[19966]: fooąęoooooooooooooooooooooooooooooooo…ąęąę python3[19968]: fooąęoooooooooooooooooąęąęąęąęąęąęąęą…ąęąę elogind[1]: Started printit.service.
Diffstat (limited to 'src/basic/string-util.c')
-rw-r--r--src/basic/string-util.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/basic/string-util.c b/src/basic/string-util.c
index 5d4510e1b..dc7de5dab 100644
--- a/src/basic/string-util.c
+++ b/src/basic/string-util.c
@@ -443,7 +443,7 @@ static char *ascii_ellipsize_mem(const char *s, size_t old_length, size_t new_le
if (old_length <= 3 || old_length <= new_length)
return strndup(s, old_length);
- r = new0(char, new_length+1);
+ r = new0(char, new_length+3);
if (!r)
return NULL;
@@ -453,12 +453,12 @@ static char *ascii_ellipsize_mem(const char *s, size_t old_length, size_t new_le
x = new_length - 3;
memcpy(r, s, x);
- r[x] = '.';
- r[x+1] = '.';
- r[x+2] = '.';
+ r[x] = 0xe2; /* tri-dot ellipsis: … */
+ r[x+1] = 0x80;
+ r[x+2] = 0xa6;
memcpy(r + x + 3,
- s + old_length - (new_length - x - 3),
- new_length - x - 3);
+ s + old_length - (new_length - x - 1),
+ new_length - x - 1);
return r;
}