Created
January 18, 2010 06:31
-
-
Save yukikaoru/279829 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# vim:set encoding=utf-8: | |
# by ruby1.9.1-p378 | |
require "dbi" | |
require "kconv" | |
DBI.connect("DBI:ODBC:foobar", "sa", "sa") do |dbh| | |
q = "select * from foo_table" | |
dbh.select_all(q) do |row| | |
row[0] = NKF.nkf("-wZ1", row[1]).strip | |
row[0] = row[0].gsub(/([a-zA-Z0-9])/){ NKF.nkf("-wWZ", $1) } | |
#=> ok | |
row[1] = row[1].gsub(/([a-zA-Z0-9])/){ NKF.nkf("-wWZ", $1) } | |
row[1] = NKF.nkf("-wZ1", row[1]).strip | |
#=> error | |
# `gsub': incompatible encoding regexp match | |
# (UTF-8 regexp with ASCII-8BIT string) | |
# (Encoding::CompatibilityError) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment