Skip to content

incompatible character encodings: ASCII-8BIT and UTF-8 Error #191

@wbzyl

Description

@wbzyl

Running:

thor test:example Þórr

on README with the content

Ł -- utf-8 encoded L slash
use rake

yields

You supplied the text: Þórr
    gsub  README
    .rvm/gems/ruby-1.9.2-p290/gems/thor-0.14.6/lib/thor/actions/file_manipulation.rb:227:in `gsub!': 
        incompatible character encodings: ASCII-8BIT and UTF-8 (Encoding::CompatibilityError)

Responsible for this is error the file test.thor:

require 'thor'

class Test < Thor
  include Thor::Actions

  desc "example TEXT", "an example task that replaces word 'rake' in README with provided TEXT"
  def example(text)
    puts "You supplied the text: #{text}"
    gsub_file 'README', /rake/ do
      "No more rake. Use #{text}"
    end
  end
end

The above means that I can't gsub a chunk of text with the Polish diacritics in a html.erb file, for example.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions