Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid multibyte char (UTF-8) with image file or font file #234

Open
plevavas opened this issue Aug 20, 2015 · 2 comments
Open

Invalid multibyte char (UTF-8) with image file or font file #234

plevavas opened this issue Aug 20, 2015 · 2 comments
Labels

Comments

@plevavas
Copy link

I try to use a custom template. It works. But, for example, when i use this font https://www.google.com/fonts/specimen/PT+Sans. I have no issue with the regular style. But if i add the bold or italic style in the resources directory, i have this issue :

/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/erb.rb:849:in `eval': (erb):34: invalid multibyte char (UTF-8) (SyntaxError)
    from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/erb.rb:849:in `result'
    from /usr/local/Cellar/liftoff/1.5.0/rubylib/liftoff/string_renderer.rb:8:in `render'
    from /usr/local/Cellar/liftoff/1.5.0/rubylib/liftoff/file_manager.rb:74:in `render_template'
    from /usr/local/Cellar/liftoff/1.5.0/rubylib/liftoff/file_manager.rb:66:in `move_template'
    from /usr/local/Cellar/liftoff/1.5.0/rubylib/liftoff/file_manager.rb:48:in `block in copy_template_directory'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/find.rb:43:in `block in find'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/find.rb:42:in `catch'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/find.rb:42:in `find'
    from /usr/local/Cellar/liftoff/1.5.0/rubylib/liftoff/file_manager.rb:46:in `copy_template_directory'
    from /usr/local/Cellar/liftoff/1.5.0/rubylib/liftoff/file_manager.rb:15:in `generate'
    from /usr/local/Cellar/liftoff/1.5.0/rubylib/liftoff/project_builder.rb:58:in `move_template'
    from /usr/local/Cellar/liftoff/1.5.0/rubylib/liftoff/project_builder.rb:32:in `add_file'
    from /usr/local/Cellar/liftoff/1.5.0/rubylib/liftoff/project_builder.rb:24:in `create_tree'
    from /usr/local/Cellar/liftoff/1.5.0/rubylib/liftoff/project_builder.rb:44:in `block (2 levels) in create_groups_for_tree'
    from /usr/local/Cellar/liftoff/1.5.0/rubylib/liftoff/project_builder.rb:43:in `each'
    from /usr/local/Cellar/liftoff/1.5.0/rubylib/liftoff/project_builder.rb:43:in `block in create_groups_for_tree'
    from /usr/local/Cellar/liftoff/1.5.0/rubylib/liftoff/project_builder.rb:37:in `each_pair'
    from /usr/local/Cellar/liftoff/1.5.0/rubylib/liftoff/project_builder.rb:37:in `create_groups_for_tree'
    from /usr/local/Cellar/liftoff/1.5.0/rubylib/liftoff/project_builder.rb:26:in `create_tree'
    from /usr/local/Cellar/liftoff/1.5.0/rubylib/liftoff/project_builder.rb:12:in `block (2 levels) in create_project'
    from /usr/local/Cellar/liftoff/1.5.0/rubylib/liftoff/project_builder.rb:11:in `each'
    from /usr/local/Cellar/liftoff/1.5.0/rubylib/liftoff/project_builder.rb:11:in `block in create_project'
    from /usr/local/Cellar/liftoff/1.5.0/rubylib/liftoff/project_builder.rb:10:in `each'
    from /usr/local/Cellar/liftoff/1.5.0/rubylib/liftoff/project_builder.rb:10:in `create_project'
    from /usr/local/Cellar/liftoff/1.5.0/rubylib/liftoff/launchpad.rb:63:in `generate_project'
    from /usr/local/Cellar/liftoff/1.5.0/rubylib/liftoff/launchpad.rb:15:in `block in liftoff'
    from /usr/local/Cellar/liftoff/1.5.0/rubylib/liftoff/file_manager.rb:5:in `chdir'
    from /usr/local/Cellar/liftoff/1.5.0/rubylib/liftoff/file_manager.rb:5:in `create_project_dir'
    from /usr/local/Cellar/liftoff/1.5.0/rubylib/liftoff/launchpad.rb:14:in `liftoff'
    from /usr/local/Cellar/liftoff/1.5.0/rubylib/liftoff/cli.rb:10:in `run'
    from /usr/local/bin/liftoff:14:in `<main>'

Here, my liftoffrc :

... 
app_target_templates:
  objc:
    - <%= project_name %>:
      - Resources
@gfontenot
Copy link
Member

Makes sense. I think we're basically assuming text-based templates, not binaries. I'd be willing to bet that this is because we're trying to pass the font through ERB, but I'd need to investigate.

@plevavas
Copy link
Author

I did some test. If i modify string_renderer.rb to catch SyntaxError exception, it works :

def render(string)
  begin
    ERB.new(string).result(@config.get_binding)
    rescue SyntaxError
      puts "We can't apply template on this file."
    end
  end
end

I don't know if it's the best solution for this issue, or if it's better to check before if the file is a binary. I know that copy font files isn't common. But i have the same issue with some images that was in Images.xcassets.

Edit :

In fact, files are corrupt after that. So, it doesn't work.

@gfontenot gfontenot added the bug label Nov 20, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants