-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
inconsistent results from isprint('\t') #7416
Comments
One potential fix might be to use Unicode character categories, as suggested in #5939. |
Note that our current |
See also this discussion, in which the MinGW developers comment that contrery [sic] to other systems,msvcrt DLL version of iswprint function returns 1 for tab character and hence specifically check for tabs in GDB's |
I don't think there is a Unicode "printable" property looking at http://www.unicode.org/reports/tr44/#Character_Properties The traditional ASCII printable has meant "not a control or delete", so space was "printable" but tab was not. |
The tab character in Unicode is in category |
fixed by #8233 |
The standard library functions ::isprint/std::isprint have platform- and locale-dependent behavior which makes LLVM's output less predictable. In particular, regression tests my fail depending on the implementation of these functions. Implement llvm::isPrint in StringExtras.h with a standard behavior and replace all uses of ::isprint/std::isprint by a call it llvm::isPrint. The function is inlined and does not look up language settings so it should perform better than the standard library's version. Such a replacement has already been done for isdigit, isalpha, isxdigit in r314883. gtest does the same in gtest-printers.cc using the following justification: // Returns true if c is a printable ASCII character. We test the // value of c directly instead of calling isprint(), which is buggy on // Windows Mobile. inline bool IsPrintableAscii(wchar_t c) { return 0x20 <= c && c <= 0x7E; } Similar issues have also been encountered by Julia: JuliaLang/julia#7416 I noticed the problem myself when on Windows isprint('\t') started to evaluate to true (see https://stackoverflow.com/questions/51435249) and thus caused several unit tests to fail. The result of isprint doesn't seem to be well-defined even for ASCII characters. Therefore I suggest to replace isprint by a platform-independent version. Differential Revision: https://reviews.llvm.org/D49680 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@338034 91177308-0d34-0410-b5e6-96231b3b80d8
As mentioned in #7402 and JuliaLang/IJulia.jl#200,
isprint('\t')
returnstrue
on Windows andfalse
on MacOS. This inconsistency seems undesirable.According to http://en.cppreference.com/w/cpp/string/byte/isprint, the correct result is
false
. However, other documentation forisprint
is vague on the topic. Sinceisprint(' ')
returnstrue
, it seems odd to me that it would return false for a tab.I'm not sure what the right answer is here, but I'm leaning towards
false
based on what non-Windows systems do.The text was updated successfully, but these errors were encountered: