Coder Social home page Coder Social logo

Comments (5)

elomarns avatar elomarns commented on June 26, 2024

The reason why the plugin adds the encoding declaration again is that it will always be sure that the encoding declaration are present when needed, and that it's never present when not needed. So if you delete it, and the plugin adds it again, the declaration is still needed, and it should not be removed as long as the file still has non-ASCII characters.

And personally I prefer this approach than add it just once. The reason why I've created this plugin is to delegate to it the task of adding and removing the encoding declaration. So when I'm using it I don't want to think about encoding declaration, this is the plugin's job.

from auto-encoding-for-ruby.

demiazz avatar demiazz commented on June 26, 2024

Ok. But one moment. If file already has encoding header - plugin try adds own header. May be, plugin should check presence of encoding header, before adds right header, or replace existing.

And how plugin work, when in file using hashbang header? (#! /env/ruby for example)

from auto-encoding-for-ruby.

elomarns avatar elomarns commented on June 26, 2024

The plugin already checks if the file has an encoding declaration, but it checks using the default encoding declaration (currently #encoding: utf-8). So If you're using an encoding declaration other than the default, the plugin will add the declaration anyway. In this case you have to set your prefered encoding declaration string, as explained here: https://github.com/elomarns/auto-encoding-for-ruby#encoding-declaration. After this, the plugin will recognize your encoding declaration.

About hashbang headers, the plugin currently ignores it and always add the encoding declaration on the first line. I didn't thought on this case before, and I agree that's not the best behaviour. So I'll eventually change it in a way that it adds the encoding declaration on the first blank line.

from auto-encoding-for-ruby.

demiazz avatar demiazz commented on June 26, 2024

Ok. =) I start experiment with analog your plugin for looking on this task, and I think about solving problem with hashbang headers. May be I can come up with some useful solution.

from auto-encoding-for-ruby.

elomarns avatar elomarns commented on June 26, 2024

Good look. :)

I'll eventually try to solve the hashbang problem as well.

from auto-encoding-for-ruby.

Related Issues (12)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.