Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
Use rb_str_conv_enc_opts to transcode error strings in MySQL < 5.5 #470
This resolves the problem in https://github.com/pwnall/rails5738 but does not pass our own specs on MySQL 5.1, as it appears to be allowing invalid UTF-8 characters through (in the case of our tests, there is a Big5-encoded Chinese character U+9020 which is not valid UTF-8 – I'm using this to test whether the transcoding is thorough).
The transcoding function calls are now:
rb_encoding *err_enc = rb_ascii8bit_encoding(); rb_error_msg = rb_str_conv_enc_opts(rb_error_msg, err_enc, conn_enc, ECONV_UNDEF_REPLACE | ECONV_INVALID_REPLACE, Qnil); rb_sql_state = rb_str_conv_enc_opts(rb_sql_state, err_enc, conn_enc, ECONV_UNDEF_REPLACE | ECONV_INVALID_REPLACE, Qnil);
I feel like I'm "almost there" - what I really want is @jrochkind's ensure_valid_encoding in C ;)
Actually, maybe my test should be changed. I get the same problem even after hacking this up to call the
And looks like there are a bunch of projects right now to backport Ruby 2.1
referenced this pull request
Jan 2, 2014
This was referenced
Jan 2, 2014
This comment has been minimized.
This comment has been minimized.Show comment Hide comment
In the latest commit, I'm using
Even in Ruby 2.1, where