From 0d93125664f3062faf940906b89c76a9df9ee901 Mon Sep 17 00:00:00 2001 From: Mahmoud Al-Qudsi Date: Fri, 22 Sep 2017 21:19:11 -0500 Subject: [PATCH] Merge pull request #4421 from krader1961/consistent-unicode Use \uXXXX consistently for unicode code points (cherry picked from commit 6b2e84be0e6d04f925ad3091e118048d9cb978f4) Backporting to 2.7.0 branch just to try and keep changes between master and this branch as minimal as possible. --- src/common.cpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/common.cpp b/src/common.cpp index be5c6bf43..27ca11930 100644 --- a/src/common.cpp +++ b/src/common.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include @@ -486,14 +487,14 @@ wchar_t *quote_end(const wchar_t *pos) { } void fish_setlocale() { - // Use the Unicode "ellipsis" symbol if it can be encoded using the current locale. - ellipsis_char = can_be_encoded(L'\x2026') ? L'\x2026' : L'$'; - - // Use the Unicode "return" symbol if it can be encoded using the current locale. - omitted_newline_char = can_be_encoded(L'\x23CE') ? L'\x23CE' : L'~'; - - // solid circle unicode character if it is able, fallback to the hash character - obfuscation_read_char = can_be_encoded(L'\u25cf') ? L'\u25cf' : L'#'; + // Use various Unicode symbols if they can be encoded using the current locale, else a simple + // ASCII char alternative. All of the can_be_encoded() invocations should return the same + // true/false value since the code points are in the BMP but we're going to be paranoid. This + // is also technically wrong if we're not in a Unicode locale but we expect (or hope) + // can_be_encoded() will return false in that case. + ellipsis_char = can_be_encoded(L'\u2026') ? L'\u2026' : L'$'; // "horizontal ellipsis" + omitted_newline_char = can_be_encoded(L'\u23CE') ? L'\u23CE' : L'~'; // "return" + obfuscation_read_char = can_be_encoded(L'\u25CF') ? L'\u25CF' : L'#'; // "black circle" } long read_blocked(int fd, void *buf, size_t count) {