diff --git a/github-linguist.gemspec b/github-linguist.gemspec index b38abb6f..dbfd58a9 100644 --- a/github-linguist.gemspec +++ b/github-linguist.gemspec @@ -13,7 +13,7 @@ Gem::Specification.new do |s| s.files = Dir['lib/**/*'] s.executables << 'linguist' - s.add_dependency 'charlock_holmes', '~> 0.7.1' + s.add_dependency 'charlock_holmes', '~> 0.7.2' s.add_dependency 'escape_utils', '~> 1.0.1' s.add_dependency 'mime-types', '~> 1.19' s.add_dependency 'pygments.rb', '~> 0.5.4' diff --git a/lib/linguist/blob_helper.rb b/lib/linguist/blob_helper.rb index 67f6eef3..15ab2d9f 100644 --- a/lib/linguist/blob_helper.rb +++ b/lib/linguist/blob_helper.rb @@ -112,6 +112,12 @@ module Linguist end end + def ruby_encoding + if hash = detect_encoding + hash[:ruby_encoding] + end + end + # Try to guess the encoding # # Returns: a Hash, with :encoding, :confidence, :type @@ -258,7 +264,7 @@ module Linguist # large) strings. begin encoded_newlines = ["\r\n", "\r", "\n"]. - map { |nl| nl.encode(encoding, "ASCII-8BIT").force_encoding(data.encoding) } + map { |nl| nl.encode(ruby_encoding, "ASCII-8BIT").force_encoding(data.encoding) } data.split(Regexp.union(encoded_newlines), -1) rescue Encoding::ConverterNotFoundError