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