9 #include <unicode/ucnv.h>
18 bool check (
const UErrorCode& iStatus,
const char* iMsg) {
19 bool oSuccessful =
true;
20 if (U_FAILURE (iStatus)) {
23 <<
" (" << iMsg <<
")");
34 UnicodeString&
appendHex (
const uint32_t iNumber, int8_t ioDigits,
35 UnicodeString& ioTarget) {
36 static const UnicodeString DIGIT_STRING (
"0123456789ABCDEF");
37 while (ioDigits > 0) {
38 ioTarget += DIGIT_STRING[(iNumber >> ((--ioDigits) * 4)) & 0xF];
45 UnicodeString
escape (
const UnicodeString& iSource) {
47 UnicodeString target (
"\"");
48 for (i = 0; i < iSource.length(); ++i) {
49 UChar ch = iSource[i];
51 if (ch < 0x09 || (ch > 0x0A && ch < 0x20) || ch > 0x7E) {
65 std::string
getUTF8 (
const UnicodeString& iString) {
66 std::ostringstream oStr;
68 const int32_t len = iString.length();
72 const int32_t bufLen = len + 256;
75 char* buf =
new char[bufLen + 1];
76 const int32_t actualLen = iString.extract (0, len, buf);
77 buf[actualLen] =
'\0';
80 delete buf; buf = NULL;
UnicodeString escape(const UnicodeString &iSource)
#define OPENTREP_LOG_ERROR(iToBeLogged)
std::string getUTF8(const UnicodeString &iString)
UnicodeString & appendHex(const uint32_t iNumber, int8_t ioDigits, UnicodeString &ioTarget)
bool check(const UErrorCode &iStatus, const char *iMsg)