1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-20 03:23:01 +02:00
llvm-mirror/lib/Support/Locale.cpp
Yaron Keren f5ea450f9d Add #include llvm-config.h to Locale.cpp which depends on LLVM_ON_WIN32.
Source code was assuming that llvm-config.h would be included somehow but
up to r247253 that added #include "llvm/Support/Compiler.h" to StringRef.h
the config file was not actually included. The inclusion of llvm-config.h
caused a change of behaviour in tools/clang/test/Frontend/source-col-map.c:
previously it would output the original UTF-8 but now it outputs <U+03B1>.

llvm-svn: 247409
2015-09-11 13:22:47 +00:00

33 lines
870 B
C++

#include "llvm/Config/llvm-config.h"
#include "llvm/Support/Locale.h"
#include "llvm/Support/Unicode.h"
namespace llvm {
namespace sys {
namespace locale {
int columnWidth(StringRef Text) {
#if LLVM_ON_WIN32
return Text.size();
#else
return llvm::sys::unicode::columnWidthUTF8(Text);
#endif
}
bool isPrint(int UCS) {
#if LLVM_ON_WIN32
// Restrict characters that we'll try to print to the lower part of ASCII
// except for the control characters (0x20 - 0x7E). In general one can not
// reliably output code points U+0080 and higher using narrow character C/C++
// output functions in Windows, because the meaning of the upper 128 codes is
// determined by the active code page in the console.
return ' ' <= UCS && UCS <= '~';
#else
return llvm::sys::unicode::isPrintable(UCS);
#endif
}
} // namespace locale
} // namespace sys
} // namespace llvm