Created
October 19, 2009 12:30
-
-
Save lennart/213327 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
| diff --git a/ext/id3lib_api/id3lib_api_wrap.cxx b/ext/id3lib_api/id3lib_api_wrap.cxx | |
| index aaae53b..a545d38 100644 | |
| --- a/ext/id3lib_api/id3lib_api_wrap.cxx | |
| +++ b/ext/id3lib_api/id3lib_api_wrap.cxx | |
| @@ -854,7 +854,6 @@ SWIG_UnpackDataName(const char *c, void *ptr, size_t sz, const char *name) { | |
| #include <ruby.h> | |
| - | |
| /* Remove global macros defined in Ruby's win32.h */ | |
| #ifdef write | |
| # undef write | |
| @@ -2106,9 +2105,8 @@ SWIGINTERN VALUE ID3_Field_get_unicode(ID3_Field *self){ | |
| return rb_str_new(str, size); | |
| } | |
| SWIGINTERN size_t ID3_Field_set_binary(ID3_Field *self,VALUE data){ | |
| - StringValue(data); | |
| - return self->Set((const uchar *)RSTRING(data)->ptr, | |
| - RSTRING(data)->len); | |
| + return self->Set((const uchar *)RSTRING_PTR(data), | |
| + RSTRING_LEN(data)); | |
| } | |
| SWIGINTERN size_t ID3_Field_set_unicode(ID3_Field *self,VALUE data){ | |
| StringValue(data); | |
| @@ -2116,14 +2114,14 @@ SWIGINTERN size_t ID3_Field_set_unicode(ID3_Field *self,VALUE data){ | |
| long len; | |
| unicode_t *unicode; | |
| - len = RSTRING(data)->len / sizeof(unicode_t); | |
| + len = RSTRING_LEN(data) / sizeof(unicode_t); | |
| unicode = (unicode_t *)malloc(sizeof(unicode_t) * (len+1)); | |
| if (unicode == NULL) { | |
| rb_raise(rb_eNoMemError, "Couldn't allocate memory for Unicode data."); | |
| } | |
| - memcpy(unicode, RSTRING(data)->ptr, sizeof(unicode_t) * len); | |
| + memcpy(unicode, RSTRING_PTR(data), sizeof(unicode_t) * len); | |
| // Unicode strings need 0x0000 at the end. | |
| unicode[len] = 0; | |
| size_t retval = self->Set(unicode); | |
| diff --git a/lib/id3lib.rb b/lib/id3lib.rb | |
| index f003e1a..9fb4250 100644 | |
| --- a/lib/id3lib.rb | |
| +++ b/lib/id3lib.rb | |
| @@ -346,7 +346,7 @@ module ID3Lib | |
| libfield.get_binary | |
| when :text | |
| if libfield.get_encoding > 0 | |
| - libfield.get_unicode | |
| + libfield.get_unicode.force_encoding("UTF-16BE").encode("UTF-8") | |
| else | |
| libfield.get_ascii | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment