pike.git / lib / modules / Sql.pmod / sql_util.pmod

version» Context lines:

pike.git/lib/modules/Sql.pmod/sql_util.pmod:233:    return row;    }       //! JSON is always utf8 default, do nothing.    int|string fetch_json_result()    {    return master_result->fetch_json_result();    }   }    - #if constant (___Mysql.mysql.HAVE_MYSQL_FIELD_CHARSETNR) -  +    class MySQLUnicodeWrapper   //! Result wrapper for MySQL that performs UTF-8 decoding of all   //! nonbinary fields. Useful if the result charset of the connection   //! has been set to UTF-8.   //!   //! @note   //! There's normally no need to use this class directly. It's used   //! automatically when @[mysql.set_unicode_decode_mode] is activated.   {    inherit UnicodeWrapper;
pike.git/lib/modules/Sql.pmod/sql_util.pmod:260: Inside #if constant (___Mysql.mysql.HAVE_MYSQL_FIELD_CHARSETNR)
   array(int|mapping(string:mixed)) field_info = fetch_fields();    foreach(row; int i; string|int val) {    if (stringp(val) && field_info[i]->charsetnr != 63) {    row[i] = utf8_to_string(val);    }    }    return row;    }   }    - #else -  +    class MySQLBrokenUnicodeWrapper - // This one is used to get a buggy unicode support when compiled with - // an old MySQL client lib that doesn't have the charsetnr property in - // the field info. It looks at the binary flag instead, which is set - // for binary fields but might also be set for text fields (e.g. with - // a definition like "VARCHAR(255) BINARY"). - // - // I.e. the effect of using this one is that text fields with the - // binary flag won't be correctly decoded in unicode decode mode. - // - // This has to be enabled either by passing "broken-unicode" as - // charset to Sql.mysql.create or Sql.mysql.set_charset, by calling - // Sql.mysql.set_unicode_decode_mode(-1), or by defining the - // environment variable PIKE_BROKEN_MYSQL_UNICODE_MODE. That will - // cause this buggy variant to be used if and only if the MySQL client - // lib doesn't support the charsetnr property. + //! This one is used to get a buggy unicode support when compiled with + //! an old MySQL client lib that doesn't have the charsetnr property in + //! the field info. It looks at the binary flag instead, which is set + //! for binary fields but might also be set for text fields (e.g. with + //! a definition like @expr{"VARCHAR(255) BINARY"@}). + //! + //! I.e. the effect of using this one is that text fields with the + //! binary flag won't be correctly decoded in unicode decode mode. + //! + //! This has to be enabled either by passing @expr{"broken-unicode"@} as + //! charset to @[Sql.mysql.create] or @[Sql.mysql.set_charset], by calling + //! @[Sql.mysql.set_unicode_decode_mode(-1)], or by defining the + //! environment variable @tt{PIKE_BROKEN_MYSQL_UNICODE_MODE@}. That will + //! cause this buggy variant to be used if and only if the MySQL client + //! lib doesn't support the charsetnr property.   {    inherit UnicodeWrapper;       int|array(string) fetch_row()    {    int|array(string) row = master_result->fetch_row();    if (!arrayp(row)) return row;    array(int|mapping(string:mixed)) field_info = fetch_fields();    foreach(row; int i; string|int val) {    if (stringp(val) && field_info[i]->flags &&    !field_info[i]->flags->binary) {    row[i] = utf8_to_string(val);    }    }    return row;    }   } -  - #endif +