Seth Cantrell | 75dbcb8 | 2012-04-17 20:03:03 +0000 | [diff] [blame] | 1 | #include "llvm/Support/Locale.h" |
Alexander Kornienko | 9aa60fd | 2013-09-04 16:00:12 +0000 | [diff] [blame] | 2 | #include "llvm/Support/Unicode.h" |
Seth Cantrell | 75dbcb8 | 2012-04-17 20:03:03 +0000 | [diff] [blame] | 3 | |
Alexander Kornienko | 9aa60fd | 2013-09-04 16:00:12 +0000 | [diff] [blame] | 4 | namespace llvm { |
| 5 | namespace sys { |
| 6 | namespace locale { |
| 7 | |
| 8 | int columnWidth(StringRef Text) { |
| 9 | #if LLVM_ON_WIN32 |
| 10 | return Text.size(); |
Seth Cantrell | 75dbcb8 | 2012-04-17 20:03:03 +0000 | [diff] [blame] | 11 | #else |
Alexander Kornienko | 9aa60fd | 2013-09-04 16:00:12 +0000 | [diff] [blame] | 12 | return llvm::sys::unicode::columnWidthUTF8(Text); |
Seth Cantrell | 75dbcb8 | 2012-04-17 20:03:03 +0000 | [diff] [blame] | 13 | #endif |
Alexander Kornienko | 9aa60fd | 2013-09-04 16:00:12 +0000 | [diff] [blame] | 14 | } |
| 15 | |
| 16 | bool isPrint(int UCS) { |
| 17 | #if LLVM_ON_WIN32 |
| 18 | // Restrict characters that we'll try to print to the the lower part of ASCII |
| 19 | // except for the control characters (0x20 - 0x7E). In general one can not |
| 20 | // reliably output code points U+0080 and higher using narrow character C/C++ |
| 21 | // output functions in Windows, because the meaning of the upper 128 codes is |
| 22 | // determined by the active code page in the console. |
| 23 | return ' ' <= UCS && UCS <= '~'; |
| 24 | #else |
| 25 | return llvm::sys::unicode::isPrintable(UCS); |
| 26 | #endif |
| 27 | } |
| 28 | |
| 29 | } // namespace locale |
| 30 | } // namespace sys |
| 31 | } // namespace llvm |