tags 665899 patch
thanks

Hello,

The current code only special-cases UTF16-LE encoding, everything else 
is simply converted to UTF-8. This causes a test failure on sparc, 
where native 16-bit encoding is UTF16-BE. As far as I can tell, the 
only effect of detecting the 16-bit encoding is to call sqlite3_open16 
instead of sqlite3_open_v2, so attached patch should do the trick. I 
verified that with it applied all tests pass on sparc and the package 
is successfully built.

Best regards, 
-- 
Jurij Smakov                                           ju...@wooyd.org
Key: http://www.wooyd.org/pgpkey/                      KeyID: C99E03CC
diff -aur a/ext/sqlite3/database.c b/ext/sqlite3/database.c
--- a/ext/sqlite3/database.c	2012-01-08 16:24:47.000000000 +0000
+++ b/ext/sqlite3/database.c	2012-04-16 16:28:44.287997708 +0100
@@ -60,7 +60,7 @@
   else Check_Type(opts, T_HASH);
 
 #ifdef HAVE_RUBY_ENCODING_H
-  if(UTF16_LE_P(file)) {
+  if(UTF16_LE_P(file) || UTF16_BE_P(file)) {
     status = sqlite3_open16(utf16_string_value_ptr(file), &ctx->db);
   } else {
 #endif
diff -aur a/ext/sqlite3/sqlite3_ruby.h b/ext/sqlite3/sqlite3_ruby.h
--- a/ext/sqlite3/sqlite3_ruby.h	2012-01-08 16:24:47.000000000 +0000
+++ b/ext/sqlite3/sqlite3_ruby.h	2012-04-16 16:28:20.315997261 +0100
@@ -21,6 +21,7 @@
 
 #define UTF8_P(_obj) (rb_enc_get_index(_obj) == rb_utf8_encindex())
 #define UTF16_LE_P(_obj) (rb_enc_get_index(_obj) == rb_enc_find_index("UTF-16LE"))
+#define UTF16_BE_P(_obj) (rb_enc_get_index(_obj) == rb_enc_find_index("UTF-16BE"))
 #define SQLITE3_UTF8_STR_NEW2(_obj) \
     (rb_enc_associate_index(rb_str_new2(_obj), rb_utf8_encindex()))
 

Reply via email to