Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/camertron/code-pages
A database of legacy Microsoft and ISO 8859 code pages for Ruby.
https://github.com/camertron/code-pages
Last synced: 18 days ago
JSON representation
A database of legacy Microsoft and ISO 8859 code pages for Ruby.
- Host: GitHub
- URL: https://github.com/camertron/code-pages
- Owner: camertron
- License: mit
- Created: 2017-12-29T02:47:45.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2018-02-06T18:01:08.000Z (almost 7 years ago)
- Last Synced: 2024-12-04T01:16:24.729Z (about 1 month ago)
- Language: Ruby
- Size: 467 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
## code-pages
A database of legacy Microsoft and ISO 8859 code pages for Ruby.## Installation
`gem install code-pages`
or put it in your Gemfile:
```ruby
gem 'code-pages'
```### What is this Thing?
Before the advent of the Unicode standard, Microsoft and other companies developed their own encoding systems to accommodate the world's many languages and writing systems. Like Unicode, each of these systems map a series of integers to characters. A group of these characters is called a code page, and a number of legacy systems still use them to represent text. Fortunately the Unicode Consortium maintains a set of data files mapping the characters used in each code page to their Unicode equivalents, making it possible to convert text from the various code page encodings to UTF-8.
### Usage
Individual code pages can be accessed directly via the `CodePages` constant:
```ruby
CodePages[37] # => #
```Get a list of all code pages via the `#all` method:
```ruby
CodePages.all # => { 37 => #, ... }
```Once you have a code page, a mapping of code page characters to Unicode code points can be obtained via the `#unicode_mapping` method:
```ruby
CodePages[37].unicode_mapping # => { 0=>0, 1=>1, 2=>2, 3=>3, 4=>156, 5=>9, ... }
```You can also convert text encoded with the code page to UTF-8 and vice-versa:
```ruby
CodePages[37].to_utf8('abc') # => '/ÂÄ'
CodePages[37].from_utf8('/ÂÄ') # => 'abc'
```## Updating Code Pages
The library comes with a rake task for downloading and updating the code pages from the Unicode Consortium's website. Run `bundle exec rake import` to update. To add additional code pages, edit resources/code_page_manifest.yml and run the rake task.
## License
Licensed under the MIT license. See LICENSE for details.
## Authors
* Cameron C. Dutro: http://github.com/camertron