diff options
Diffstat (limited to 'src/common.cpp')
-rw-r--r-- | src/common.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/common.cpp b/src/common.cpp index 21c4b92c..2aa76cc5 100644 --- a/src/common.cpp +++ b/src/common.cpp @@ -795,6 +795,24 @@ void format_long_safe(wchar_t buff[64], long val) } } +void narrow_string_safe(char buff[64], const wchar_t *s) +{ + size_t idx = 0; + for (size_t widx = 0; s[widx] != L'\0'; widx++) + { + wchar_t c = s[widx]; + if (c <= 127) + { + buff[idx++] = char(c); + if (idx + 1 == 64) + { + break; + } + } + } + buff[idx] = '\0'; +} + wcstring reformat_for_screen(const wcstring &msg) { wcstring buff; |