Skip to content

Instantly share code, notes, and snippets.

@marnen
Created October 26, 2010 19:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marnen/647612 to your computer and use it in GitHub Desktop.
Save marnen/647612 to your computer and use it in GitHub Desktop.
Errors when inserting UTF-8 characters into MS SQL Server database with TinyTds
>> db = TinyTds::Client.new :username => 'USER', :password => 'PASSWORD', :dataserver => 'SERVER', :database => 'DB', :encoding => 'UTF-8'
=> #<TinyTds::Client:0x101174a88>
>> db.encoding
=> nil
>> r = db.execute "insert into awards (title) values ('Japanese')"
=> #<TinyTds::Result:0x101167810>
>> r.each
=> []
>> r = db.execute "insert into awards (title) values ('Japanese 日本語です')"
=> #<TinyTds::Result:0x101155188>
>> r.each
=> []
>> r = db.execute "select * from awards where id = 28"=> #<TinyTds::Result:0x10114d258>
>> r.each
=> [{"label"=>nil, "created_at"=>nil, "title"=>"Japanese ?????", "updated_at"=>nil, "id"=>28, "has_scores"=>false, "description"=>nil, "award_type_id"=>nil}]
>> r.first['title']
=> "Japanese ?????"
>> $KCODE
=> "UTF8"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment