Permalink
Browse files

Merge branch 'master' of git://github.com/envato/exiv2

Conflicts:
	Gemfile.lock
  • Loading branch information...
2 parents c5f5887 + 56dc0bd commit bac14938acd982bfcf2cca0f80304b4af06c8e7c @paulsponagl committed Apr 3, 2012
View
@@ -10,3 +10,4 @@ mkmf.log
*.dSYM
pkg
tmp
+bin
View
1 .rspec
@@ -0,0 +1 @@
+--colour
View
@@ -1,4 +1,3 @@
source "http://rubygems.org"
-# Specify your gem's dependencies in exiv2.gemspec
-gemspec
+gemspec
View
@@ -0,0 +1,28 @@
+PATH
+ remote: .
+ specs:
+ exiv2 (0.0.6)
+
+GEM
+ remote: http://rubygems.org/
+ specs:
+ diff-lcs (1.1.3)
+ rake (0.9.2.2)
+ rake-compiler (0.8.0)
+ rake
+ rspec (2.8.0)
+ rspec-core (~> 2.8.0)
+ rspec-expectations (~> 2.8.0)
+ rspec-mocks (~> 2.8.0)
+ rspec-core (2.8.0)
+ rspec-expectations (2.8.0)
+ diff-lcs (~> 1.1.2)
+ rspec-mocks (2.8.0)
+
+PLATFORMS
+ ruby
+
+DEPENDENCIES
+ exiv2!
+ rake-compiler
+ rspec
View
@@ -3,7 +3,14 @@
// Create a Ruby string from a C++ std::string.
static VALUE to_ruby_string(const std::string& string) {
- return rb_str_new(string.data(), string.length());
+ VALUE str = rb_str_new(string.data(), string.length());
+
+ // force UTF-8 encoding in Ruby 1.9+
+ ID forceEncodingId = rb_intern("force_encoding");
+ if(rb_respond_to(str, forceEncodingId)) {
+ rb_funcall(str, forceEncodingId, 1, rb_str_new("UTF-8", 5));
+ }
+ return str;
}
// Create a C++ std::string from a Ruby string.
View
@@ -1,3 +1,4 @@
+# coding: utf-8
require 'exiv2/exiv2'
require 'exiv2/shared_methods'
require 'exiv2/exif_data'
View
@@ -1,3 +1,4 @@
+# coding: utf-8
class Exiv2::ExifData
include SharedMethods
end
View
@@ -1,3 +1,4 @@
+# coding: utf-8
class Exiv2::IptcData
include SharedMethods
end
@@ -1,3 +1,4 @@
+# coding: utf-8
module SharedMethods
def to_hash
result = {}
View
@@ -1,3 +1,4 @@
+# coding: utf-8
module Exiv2
- VERSION = "0.0.6"
+ VERSION = "0.0.8"
end
View
@@ -1,3 +1,4 @@
+# coding: utf-8
class Exiv2::XmpData
include SharedMethods
end
View
@@ -1,3 +1,5 @@
+# coding: utf-8
+require 'bundler/setup'
require 'exiv2'
require 'fileutils'
require 'rational'
@@ -39,6 +41,27 @@ def rational(a, b)
image2.iptc_data["Iptc.Application2.Caption"].should == "A New Caption"
FileUtils.rm("spec/files/test_tmp.jpg")
end
+
+ it 'reads UTF-8 data' do
+ image = Exiv2::ImageFactory.open(Pathname.new("spec/files/photo_with_utf8_description.jpg").to_s)
+ image.read_metadata
+ description = image.exif_data["Exif.Image.ImageDescription"]
+ if description.respond_to? :encoding # Only in Ruby 1.9+
+ description.encoding.should == Encoding::UTF_8
+ end
+ description.should == 'UTF-8 description. ☃ł㌎'
+ end
+
+ it 'reads UTF-8 data in each' do
+ if String.new.respond_to? :encoding # Only in Ruby 1.9+
+ image = Exiv2::ImageFactory.open(Pathname.new("spec/files/photo_with_utf8_description.jpg").to_s)
+ image.read_metadata
+ image.exif_data.each do |key,value|
+ key.encoding.should == Encoding::UTF_8
+ value.encoding.should == Encoding::UTF_8
+ end
+ end
+ end
let(:image) do
image = Exiv2::ImageFactory.open("spec/files/test.jpg")
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit bac1493

Please sign in to comment.