Fix display non-ascii character.#1299
Merged
koutcher merged 1 commit intojonas:masterfrom Oct 28, 2023
nonakap:fix-display-non-ascii-character
Merged
Fix display non-ascii character.#1299koutcher merged 1 commit intojonas:masterfrom nonakap:fix-display-non-ascii-character
koutcher merged 1 commit intojonas:masterfrom
nonakap:fix-display-non-ascii-character
Conversation
Collaborator
|
Thank you @nonakap. Your proposed correction has the exact opposite effect on macOS, it works without and it doesn't work with, but it certainly goes in the right direction. Could you try the following ? diff --git a/src/string.c b/src/string.c
index a90fc1bb..4cb0910b 100644
--- a/src/string.c
+++ b/src/string.c
@@ -103,7 +103,7 @@ string_expand(char *dst, size_t dstlen, const char *src, int srclen, int tabsize
expanded = dstlen - size - 1;
memcpy(dst + size, " ", expanded);
size += expanded;
- } else if (isspace((unsigned char)c) || iscntrl((unsigned char)c)) {
+ } else if (iswspace(c) || iswcntrl(c)) {
dst[size++] = ' ';
} else {
dst[size++] = src[pos];
@@ -119,7 +119,7 @@ string_trim_end(char *name)
{
int namelen = strlen(name) - 1;
- while (namelen > 0 && isspace((unsigned char)name[namelen]))
+ while (namelen > 0 && iswspace(name[namelen]))
name[namelen--] = 0;
return name;
@@ -128,7 +128,7 @@ string_trim_end(char *name)
char *
string_trim(char *name)
{
- while (isspace((unsigned char)*name))
+ while (iswspace(*name))
name++;
return string_trim_end(name);EDIT: actually this is a macOS thing only, we'll handle it with a specific case. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Should cast the argument passed to is*() function in ctype.h to unsigned char.
See https://wiki.sei.cmu.edu/confluence/display/c/STR37-C.+Arguments+to+character-handling+functions+must+be+representable+as+an+unsigned+char.
Should fix #1294.
before:

The commit log contains Japanese characters, but they are not displayed correctly.
after:

The commit log is displayed correctly.