Created
May 14, 2009 15:37
-
-
Save metaskills/111719 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
# Ruby: 1.9.1p0 (2009-01-30 revision 21907) [i386-darwin9] | |
# Using a both types of encoded string literals | |
>> ud1 = "\344\270\200\344\272\21434\344\272\224\345\205\255" | |
=> "\xE4\xB8\x80\xE4\xBA\x8C34\xE4\xBA\x94\xE5\x85\xAD" | |
>> d1 = SqlServerUnicode.create!(:nvarchar => ud1) | |
=> #<SqlServerUnicode id: 12, nchar: nil, nvarchar: "一二34五六", ntext: nil, ntext_10: nil, nchar_10: nil, nvarchar_100: nil> | |
>> d1.reload.nvarchar | |
=> "一二34五六" | |
>> | |
?> ud2 = "\344\270\200\344\272\21434\344\272\224\345\205\255".force_encoding('UTF-8') | |
=> "一二34五六" | |
>> d2 = SqlServerUnicode.create!(:nvarchar => ud2) | |
=> #<SqlServerUnicode id: 13, nchar: nil, nvarchar: "一二34五六", ntext: nil, ntext_10: nil, nchar_10: nil, nvarchar_100: nil> | |
>> d2.reload.nvarchar | |
=> "一二34五六" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment