GithubHelp home page GithubHelp logo

mojibake's Introduction

MojiBake

Description

Mojibake occurs in English most frequently due to misinterpreting and bad-transcoding between Windows-1252, ISO-8859-1, and UTF-8. This module provides a mojibake sequence to original character mapping table, and utility to recover mojibake’d text.

Testing has been with English but other Latin based languages, where Windows-1252 is in the wild, should also benefit.

Dependencies

Mojibake mappings generation requires the String encoding support in ruby 1.9 as provided by:

  • ruby >= 1.9.2 (tested 1.9.2p290, 1.9.3p392, 2.0.0p247 Linux)

  • jruby ~> 1.6.5 or ~> 1.7.5 (tested 1.6.8, 1.7.5 Linux)

  • rubinius >= 2.0.0 (tested via Travis CI)

Note: jruby versions 1.7.0-1.7.4 have various encoding support regressions. Recovery of text with default settings is supported by using the pre-generated table.json when in ruby 1.8 mode, or for other jruby versions.

Synopsis

gem install mojibake

require 'mojibake'
mapper = MojiBake::Mapper.new
mapper.recover( '“quotedâ€�' ) #=> '“quoted”'

Or via cli:

mojibake -h

List the mojibake mapping table (output in UTF-8):

mojibake -t

Recover from a text file:

mojibake input.txt

License

Copyright © 2011-2015 David Kellum

Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at:

www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

mojibake's People

Contributors

dekellum avatar andygeers avatar maciejkowalski avatar

Watchers

James Cloos avatar

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.