void CouchbaseEmbedFunctionContext::getDecimalResult(Decimal &value) { auto text = nextResultScalar(); if (text && *text) value.setString(rtlUtf8Length(strlen(text), text), text); else { NullFieldProcessor p(NULL); value.set(p.decimalResult); } }
void CouchbaseEmbedFunctionContext::getUnicodeResult(size32_t &chars, UChar * &result) { auto value = nextResultScalar(); if (value && *value) { unsigned numchars = rtlUtf8Length(strlen(value), value); rtlUtf8ToUnicodeX(chars, result, numchars, value); } NullFieldProcessor p(NULL); rtlUnicodeToUnicodeX(chars, result, p.resultChars, p.unicodeResult); }
void ViewFieldTransformer::transform(MemoryAttr & utfTarget, const MemoryAttr & utfSrc) { //NB: The system utf8 functions typically take a length, whilst MemoryAttr provide a size. unsigned lenTarget; char * target; const char * source = static_cast<const char *>(utfSrc.get()); unsigned lenSource = rtlUtf8Length(utfSrc.length(), source); transform(lenTarget, target, lenSource, source); unsigned sizeTarget = rtlUtf8Size(lenTarget, target); utfTarget.setOwn(sizeTarget, target); }
void CouchbaseRowBuilder::getUnicodeResult(const RtlFieldInfo *field, size32_t &chars, UChar * &result) { const char * value = nextField(field); if (!value || !*value) { NullFieldProcessor p(field); rtlUnicodeToUnicodeX(chars, result, p.resultChars, p.unicodeResult); return; } unsigned numchars = rtlUtf8Length(strlen(value), value); // MORE - is it a good assumption that it is utf8 ? Depends how the database is configured I think rtlUtf8ToUnicodeX(chars, result, numchars, value); return; }
static void getUnicodeResult(const RtlFieldInfo *field, const MYSQL_BIND &bound, size32_t &chars, UChar * &result) { if (*bound.is_null) { NullFieldProcessor p(field); rtlUnicodeToUnicodeX(chars, result, p.resultChars, p.unicodeResult); return; } if (bound.buffer_type != MYSQL_TYPE_STRING && bound.buffer_type != MYSQL_TYPE_VAR_STRING) typeError("string", field); const char *text = (const char *) bound.buffer; unsigned long bytes = *bound.length; unsigned numchars = rtlUtf8Length(bytes, text); // MORE - is it a good assumption that it is utf8 ? Depends how the database is configured I think rtlUtf8ToUnicodeX(chars, result, numchars, text); }
static void getUTF8Result(const RtlFieldInfo *field, sqlite3_value *val, size32_t &chars, char * &result) { assertex(val); if (isNull(val)) { NullFieldProcessor p(field); rtlUtf8ToUtf8X(chars, result, p.resultChars, p.stringResult); return; } if (sqlite3_value_type(val) != SQLITE_TEXT) typeError("string", field); const char *text = (const char *) sqlite3_value_text(val); int bytes = sqlite3_value_bytes(val); unsigned numchars = rtlUtf8Length(bytes, text); rtlUtf8ToUtf8X(chars, result, numchars, text); }
static void getUTF8Result(const RtlFieldInfo *field, const MYSQL_BIND &bound, size32_t &chars, char * &result) { if (*bound.is_null) { NullFieldProcessor p(field); rtlUtf8ToUtf8X(chars, result, p.resultChars, p.stringResult); return; } if (isDateTime(bound.buffer_type)) { getDateTimeText(bound, chars, result); return; } if (!isString(bound.buffer_type)) typeError("string", field); const char *text = (const char *) bound.buffer; unsigned long bytes = *bound.length; unsigned numchars = rtlUtf8Length(bytes, text); // MORE - is it a good assumption that it is utf8 ? Depends how the database is configured I think rtlUtf8ToUtf8X(chars, result, numchars, text); }