Locale.cpp revision 261991
1234971Sdim#include "llvm/Support/Locale.h"
2261991Sdim#include "llvm/Support/Unicode.h"
3234971Sdim
4261991Sdimnamespace llvm {
5261991Sdimnamespace sys {
6261991Sdimnamespace locale {
7261991Sdim
8261991Sdimint columnWidth(StringRef Text) {
9261991Sdim#if LLVM_ON_WIN32
10261991Sdim  return Text.size();
11234971Sdim#else
12261991Sdim  return llvm::sys::unicode::columnWidthUTF8(Text);
13234971Sdim#endif
14261991Sdim}
15261991Sdim
16261991Sdimbool isPrint(int UCS) {
17261991Sdim#if LLVM_ON_WIN32
18261991Sdim  // Restrict characters that we'll try to print to the the lower part of ASCII
19261991Sdim  // except for the control characters (0x20 - 0x7E). In general one can not
20261991Sdim  // reliably output code points U+0080 and higher using narrow character C/C++
21261991Sdim  // output functions in Windows, because the meaning of the upper 128 codes is
22261991Sdim  // determined by the active code page in the console.
23261991Sdim  return ' ' <= UCS && UCS <= '~';
24261991Sdim#else
25261991Sdim  return llvm::sys::unicode::isPrintable(UCS);
26261991Sdim#endif
27261991Sdim}
28261991Sdim
29261991Sdim} // namespace locale
30261991Sdim} // namespace sys
31261991Sdim} // namespace llvm
32