예제 #1
0
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);
}
예제 #2
0
 virtual void processUtf8(unsigned len, const char *value, const RtlFieldInfo * field)
 {
     size32_t utf8chars;
     char *utf8;
     rtlUtf8ToUtf8X(utf8chars, utf8, len, value);
     MYSQL_BIND &bindInfo = createBindBuffer(MYSQL_TYPE_STRING, 0);
     bindInfo.buffer = utf8;
     bindInfo.buffer_length = rtlUtf8Size(utf8chars, utf8);
     bindInfo.length = &bindInfo.buffer_length;
 }
예제 #3
0
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);
}