Locale.cpp 834 B

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