blob: 35ddf7f11bf62e3086e8d60b9013225c5b99c085 [file] [log] [blame]
Seth Cantrell75dbcb82012-04-17 20:03:03 +00001#include "llvm/Support/Locale.h"
Alexander Kornienko9aa60fd2013-09-04 16:00:12 +00002#include "llvm/Support/Unicode.h"
Seth Cantrell75dbcb82012-04-17 20:03:03 +00003
Alexander Kornienko9aa60fd2013-09-04 16:00:12 +00004namespace llvm {
5namespace sys {
6namespace locale {
7
8int columnWidth(StringRef Text) {
9#if LLVM_ON_WIN32
10 return Text.size();
Seth Cantrell75dbcb82012-04-17 20:03:03 +000011#else
Alexander Kornienko9aa60fd2013-09-04 16:00:12 +000012 return llvm::sys::unicode::columnWidthUTF8(Text);
Seth Cantrell75dbcb82012-04-17 20:03:03 +000013#endif
Alexander Kornienko9aa60fd2013-09-04 16:00:12 +000014}
15
16bool 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