-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 9433a7e
Showing
19 changed files
with
1,433 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Automatically normalize line endings for all text-based files | ||
* text=auto |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Coverage report | ||
coverage | ||
|
||
# Installed npm modules | ||
node_modules | ||
|
||
# Folder view configuration files | ||
.DS_Store | ||
Desktop.ini | ||
|
||
# Thumbnail cache files | ||
._* | ||
Thumbs.db | ||
|
||
# Files that might appear on external disks | ||
.Spotlight-V100 | ||
.Trashes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
language: node_js | ||
node_js: | ||
- "0.10" | ||
before_script: | ||
- "npm install -g grunt-cli" | ||
# Narwhal uses a hardcoded path to openjdk v6, so use that version | ||
- "sudo apt-get update -qq" | ||
- "sudo apt-get install -qq openjdk-6-jre" | ||
- "PACKAGE=rhino1_7R3; wget http://ftp.mozilla.org/pub/mozilla.org/js/$PACKAGE.zip && sudo unzip $PACKAGE -d /opt/ && rm $PACKAGE.zip" | ||
- "PACKAGE=rhino1_7R3; echo -e '#!/bin/sh\\njava -jar /opt/'$PACKAGE'/js.jar $@' | sudo tee /usr/local/bin/rhino && sudo chmod +x /usr/local/bin/rhino" | ||
- "PACKAGE=ringojs-0.9; wget http://ringojs.org/downloads/$PACKAGE.zip && sudo unzip $PACKAGE -d /opt/ && rm $PACKAGE.zip" | ||
- "PACKAGE=ringojs-0.9; sudo ln -s /opt/$PACKAGE/bin/ringo /usr/local/bin/ringo && sudo chmod +x /usr/local/bin/ringo" | ||
- "PACKAGE=v0.3.2; wget https://github.com/280north/narwhal/archive/$PACKAGE.zip && sudo unzip $PACKAGE -d /opt/ && rm $PACKAGE.zip" | ||
- "PACKAGE=narwhal-0.3.2; sudo ln -s /opt/$PACKAGE/bin/narwhal /usr/local/bin/narwhal && sudo chmod +x /usr/local/bin/narwhal" | ||
# If the enviroment stores rt.jar in a different directory, find it and symlink the directory | ||
- "PREFIX=/usr/lib/jvm; if [ ! -d $PREFIX/java-6-openjdk ]; then for d in $PREFIX/java-6-openjdk-*; do if [ -e $d/jre/lib/rt.jar ]; then sudo ln -s $d $PREFIX/java-6-openjdk; break; fi; done; fi" | ||
script: | ||
"grunt ci" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
module.exports = function(grunt) { | ||
|
||
grunt.initConfig({ | ||
'shell': { | ||
'options': { | ||
'stdout': true, | ||
'stderr': true, | ||
'failOnError': true | ||
}, | ||
'fetch': { | ||
'command': 'curl http://encoding.spec.whatwg.org/index-koi8-r.txt > data/index.txt' | ||
}, | ||
'transform-data': { | ||
'command': 'node scripts/transform-data.js' | ||
}, | ||
'cover': { | ||
'command': 'istanbul cover --report "html" --verbose --dir "coverage" "tests/tests.js"' | ||
}, | ||
'test-narwhal': { | ||
'command': 'echo "Testing in Narwhal..."; export NARWHAL_OPTIMIZATION=-1; narwhal "tests/tests.js"' | ||
}, | ||
'test-phantomjs': { | ||
'command': 'echo "Testing in PhantomJS..."; phantomjs "tests/tests.js"' | ||
}, | ||
// Rhino 1.7R4 has a bug that makes it impossible to test in. | ||
// https://bugzilla.mozilla.org/show_bug.cgi?id=775566 | ||
// To test, use Rhino 1.7R3, or wait (heh) for the 1.7R5 release. | ||
'test-rhino': { | ||
'command': 'echo "Testing in Rhino..."; rhino -opt -1 "tests.js"', | ||
'options': { | ||
'execOptions': { | ||
'cwd': 'tests' | ||
} | ||
} | ||
}, | ||
'test-ringo': { | ||
'command': 'echo "Testing in Ringo..."; ringo -o -1 "tests/tests.js"' | ||
}, | ||
'test-node': { | ||
'command': 'echo "Testing in Node..."; node "tests/tests.js"' | ||
}, | ||
'test-browser': { | ||
'command': 'echo "Testing in a browser..."; open "tests/index.html"' | ||
} | ||
}, | ||
'template': { | ||
'build': { | ||
'options': { | ||
'data': function() { | ||
return require('./scripts/export-data.js'); | ||
} | ||
}, | ||
'files': { | ||
'koi8r.js': ['src/koi8r.js'] | ||
} | ||
}, | ||
'build-tests': { | ||
'options': { | ||
'data': function() { | ||
return require('./scripts/export-data.js'); | ||
} | ||
}, | ||
'files': { | ||
'tests/tests.js': ['tests/tests.src.js'] | ||
} | ||
} | ||
} | ||
}); | ||
|
||
grunt.loadNpmTasks('grunt-shell'); | ||
grunt.loadNpmTasks('grunt-template'); | ||
|
||
grunt.registerTask('cover', 'shell:cover'); | ||
grunt.registerTask('ci', [ | ||
'template', | ||
'shell:test-narwhal', | ||
'shell:test-phantomjs', | ||
'shell:test-rhino', | ||
'shell:test-ringo', | ||
'shell:test-node', | ||
]); | ||
grunt.registerTask('test', [ | ||
'ci', | ||
'shell:test-browser' | ||
]); | ||
|
||
grunt.registerTask('fetch', [ | ||
'shell:fetch', | ||
'build' | ||
]); | ||
|
||
grunt.registerTask('build', [ | ||
'shell:transform-data', | ||
'default' | ||
]); | ||
|
||
grunt.registerTask('default', [ | ||
'template', | ||
'shell:test-node' | ||
]); | ||
|
||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
Copyright Mathias Bynens <http://mathiasbynens.be/> | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining | ||
a copy of this software and associated documentation files (the | ||
"Software"), to deal in the Software without restriction, including | ||
without limitation the rights to use, copy, modify, merge, publish, | ||
distribute, sublicense, and/or sell copies of the Software, and to | ||
permit persons to whom the Software is furnished to do so, subject to | ||
the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be | ||
included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE | ||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | ||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | ||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
# koi8-r [![Build status](https://travis-ci.org/mathiasbynens/koi8-r.svg?branch=master)](https://travis-ci.org/mathiasbynens/koi8-r) [![Dependency status](https://gemnasium.com/mathiasbynens/koi8-r.svg)](https://gemnasium.com/mathiasbynens/koi8-r) | ||
|
||
_koi8-r_ is robust JavaScript implementation of [the koi8-r character encoding as defined by the Encoding Standard](http://encoding.spec.whatwg.org/#koi8-r). | ||
|
||
This encoding is known under the following names: cskoi8r, koi, koi8, koi8-r, koi8_r, and koi8_r. | ||
|
||
## Installation | ||
|
||
Via [npm](http://npmjs.org/): | ||
|
||
```bash | ||
npm install koi8-r | ||
``` | ||
|
||
Via [Bower](http://bower.io/): | ||
|
||
```bash | ||
bower install koi8-r | ||
``` | ||
|
||
Via [Component](https://github.com/component/component): | ||
|
||
```bash | ||
component install mathiasbynens/koi8-r | ||
``` | ||
|
||
In a browser: | ||
|
||
```html | ||
<script src="koi8-r.js"></script> | ||
``` | ||
|
||
In [Narwhal](http://narwhaljs.org/), [Node.js](http://nodejs.org/), and [RingoJS](http://ringojs.org/): | ||
|
||
```js | ||
var koi8r = require('koi8-r'); | ||
``` | ||
|
||
In [Rhino](http://www.mozilla.org/rhino/): | ||
|
||
```js | ||
load('koi8r.js'); | ||
``` | ||
|
||
Using an AMD loader like [RequireJS](http://requirejs.org/): | ||
|
||
```js | ||
require( | ||
{ | ||
'paths': { | ||
'koi8r': 'path/to/koi8r' | ||
} | ||
}, | ||
['koi8r'], | ||
function(koi8r) { | ||
console.log(koi8r); | ||
} | ||
); | ||
``` | ||
|
||
## API | ||
|
||
### `koi8r.version` | ||
|
||
A string representing the semantic version number. | ||
|
||
### `koi8r.encode(input, options)` | ||
|
||
This function takes a plain text string (the `input` parameter) and encodes it according to koi8-r. The return value is a ‘byte string’, i.e. a string of which each item represents an octet as per koi8-r. | ||
|
||
```js | ||
var encodedData = koi8r.encode(text); | ||
``` | ||
|
||
The optional `options` object and its `mode` property can be used to set the [error mode](http://encoding.spec.whatwg.org/#error-mode). For encoding, the error mode can be `'fatal'` (the default) or `'html'`. | ||
|
||
```js | ||
var encodedData = koi8r.encode(text, { | ||
'mode': 'html' | ||
}); | ||
// If `text` contains a symbol that cannot be represented in koi8-r, | ||
// instead of throwing an error, it will return an HTML entity for the symbol. | ||
``` | ||
|
||
### `koi8r.decode(input, options)` | ||
|
||
This function takes a byte string (the `input` parameter) and decodes it according to koi8-r. | ||
|
||
```js | ||
var text = koi8r.decode(encodedData); | ||
``` | ||
|
||
The optional `options` object and its `mode` property can be used to set the [error mode](http://encoding.spec.whatwg.org/#error-mode). For decoding, the error mode can be `'replacement'` (the default) or `'fatal'`. | ||
|
||
```js | ||
var text = koi8r.decode(encodedData, { | ||
'mode': 'fatal' | ||
}); | ||
// If `encodedData` contains an invalid byte for the koi8-r encoding, | ||
// instead of replacing it with U+FFFD in the output, an error is thrown. | ||
``` | ||
|
||
## Support | ||
|
||
_koi8-r_ is designed to work in at least Node.js v0.10.0, Narwhal 0.3.2, RingoJS 0.8-0.9, PhantomJS 1.9.0, Rhino 1.7RC4, as well as old and modern versions of Chrome, Firefox, Safari, Opera, and Internet Explorer. | ||
|
||
## Unit tests & code coverage | ||
|
||
After cloning this repository, run `npm install` to install the dependencies needed for development and testing. You may want to install Istanbul _globally_ using `npm install istanbul -g`. | ||
|
||
Once that’s done, you can run the unit tests in Node using `npm test` or `node tests/tests.js`. To run the tests in Rhino, Ringo, Narwhal, and web browsers as well, use `grunt test`. | ||
|
||
To generate the code coverage report, use `grunt cover`. | ||
|
||
## Author | ||
|
||
| [![twitter/mathias](https://gravatar.com/avatar/24e08a9ea84deb17ae121074d0f17125?s=70)](https://twitter.com/mathias "Follow @mathias on Twitter") | | ||
|---| | ||
| [Mathias Bynens](http://mathiasbynens.be/) | | ||
|
||
## License | ||
|
||
_koi8-r_ is available under the [MIT](http://mths.be/mit) license. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
"\u2500\u2502\u250C\u2510\u2514\u2518\u251C\u2524\u252C\u2534\u253C\u2580\u2584\u2588\u258C\u2590\u2591\u2592\u2593\u2320\u25A0\u2219\u221A\u2248\u2264\u2265\u00A0\u2321\u00B0\u00B2\u00B7\u00F7\u2550\u2551\u2552\u0451\u2553\u2554\u2555\u2556\u2557\u2558\u2559\u255A\u255B\u255C\u255D\u255E\u255F\u2560\u2561\u0401\u2562\u2563\u2564\u2565\u2566\u2567\u2568\u2569\u256A\u256B\u256C\u00A9\u044E\u0430\u0431\u0446\u0434\u0435\u0444\u0433\u0445\u0438\u0439\u043A\u043B\u043C\u043D\u043E\u043F\u044F\u0440\u0441\u0442\u0443\u0436\u0432\u044C\u044B\u0437\u0448\u044D\u0449\u0447\u044A\u042E\u0410\u0411\u0426\u0414\u0415\u0424\u0413\u0425\u0418\u0419\u041A\u041B\u041C\u041D\u041E\u041F\u042F\u0420\u0421\u0422\u0423\u0416\u0412\u042C\u042B\u0417\u0428\u042D\u0429\u0427\u042A" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
"\u0080\u0081\u0082\u0083\u0084\u0085\u0086\u0087\u0088\u0089\u008A\u008B\u008C\u008D\u008E\u008F\u0090\u0091\u0092\u0093\u0094\u0095\u0096\u0097\u0098\u0099\u009A\u009B\u009C\u009D\u009E\u009F\u00A0\u00A1\u00A2\u00A3\u00A4\u00A5\u00A6\u00A7\u00A8\u00A9\u00AA\u00AB\u00AC\u00AD\u00AE\u00AF\u00B0\u00B1\u00B2\u00B3\u00B4\u00B5\u00B6\u00B7\u00B8\u00B9\u00BA\u00BB\u00BC\u00BD\u00BE\u00BF\u00C0\u00C1\u00C2\u00C3\u00C4\u00C5\u00C6\u00C7\u00C8\u00C9\u00CA\u00CB\u00CC\u00CD\u00CE\u00CF\u00D0\u00D1\u00D2\u00D3\u00D4\u00D5\u00D6\u00D7\u00D8\u00D9\u00DA\u00DB\u00DC\u00DD\u00DE\u00DF\u00E0\u00E1\u00E2\u00E3\u00E4\u00E5\u00E6\u00E7\u00E8\u00E9\u00EA\u00EB\u00EC\u00ED\u00EE\u00EF\u00F0\u00F1\u00F2\u00F3\u00F4\u00F5\u00F6\u00F7\u00F8\u00F9\u00FA\u00FB\u00FC\u00FD\u00FE\u00FF" |
Oops, something went wrong.