Locale.cpp revision 261991
1193326Sed#include "llvm/Support/Locale.h"
2193326Sed#include "llvm/Support/Unicode.h"
3193326Sed
4193326Sednamespace llvm {
5193326Sednamespace sys {
6193326Sednamespace locale {
7193326Sed
8193326Sedint columnWidth(StringRef Text) {
9193326Sed#if LLVM_ON_WIN32
10193326Sed  return Text.size();
11193326Sed#else
12193326Sed  return llvm::sys::unicode::columnWidthUTF8(Text);
13193326Sed#endif
14193326Sed}
15193326Sed
16193326Sedbool isPrint(int UCS) {
17218893Sdim#if LLVM_ON_WIN32
18193326Sed  // Restrict characters that we'll try to print to the the lower part of ASCII
19226633Sdim  // except for the control characters (0x20 - 0x7E). In general one can not
20193326Sed  // reliably output code points U+0080 and higher using narrow character C/C++
21234353Sdim  // output functions in Windows, because the meaning of the upper 128 codes is
22193326Sed  // determined by the active code page in the console.
23193326Sed  return ' ' <= UCS && UCS <= '~';
24193326Sed#else
25193326Sed  return llvm::sys::unicode::isPrintable(UCS);
26198092Srdivacky#endif
27193326Sed}
28193326Sed
29193326Sed} // namespace locale
30193326Sed} // namespace sys
31193326Sed} // namespace llvm
32193326Sed