aboutsummaryrefslogtreecommitdiff
path: root/node_modules/is-utf8
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2016-10-10 03:43:44 +0200
committerFlorian Dold <florian.dold@gmail.com>2016-10-10 03:43:44 +0200
commitabd94a7f5a50f43c797a11b53549ae48fff667c3 (patch)
treeab8ed457f65cdd72e13e0571d2975729428f1551 /node_modules/is-utf8
parenta0247c6a3fd6a09a41a7e35a3441324c4dcb58be (diff)
downloadwallet-core-abd94a7f5a50f43c797a11b53549ae48fff667c3.tar.xz
add node_modules to address #4364
Diffstat (limited to 'node_modules/is-utf8')
-rw-r--r--node_modules/is-utf8/LICENSE9
-rw-r--r--node_modules/is-utf8/README.md16
-rw-r--r--node_modules/is-utf8/is-utf8.js76
-rw-r--r--node_modules/is-utf8/package.json87
4 files changed, 188 insertions, 0 deletions
diff --git a/node_modules/is-utf8/LICENSE b/node_modules/is-utf8/LICENSE
new file mode 100644
index 000000000..2c8d4b999
--- /dev/null
+++ b/node_modules/is-utf8/LICENSE
@@ -0,0 +1,9 @@
+The MIT License (MIT)
+
+Copyright (C) 2014 Wei Fanzhe
+
+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.
diff --git a/node_modules/is-utf8/README.md b/node_modules/is-utf8/README.md
new file mode 100644
index 000000000..b62ddde1c
--- /dev/null
+++ b/node_modules/is-utf8/README.md
@@ -0,0 +1,16 @@
+#utf8 detector
+
+Detect if a Buffer is utf8 encoded.
+It need The minimum amount of bytes is 4.
+
+
+```javascript
+ var fs = require('fs');
+ var isUtf8 = require('is-utf8');
+ var ansi = fs.readFileSync('ansi.txt');
+ var utf8 = fs.readFileSync('utf8.txt');
+
+ console.log('ansi.txt is utf8: '+isUtf8(ansi)); //false
+ console.log('utf8.txt is utf8: '+isUtf8(utf8)); //true
+```
+
diff --git a/node_modules/is-utf8/is-utf8.js b/node_modules/is-utf8/is-utf8.js
new file mode 100644
index 000000000..8a5f15d13
--- /dev/null
+++ b/node_modules/is-utf8/is-utf8.js
@@ -0,0 +1,76 @@
+
+exports = module.exports = function(bytes)
+{
+ var i = 0;
+ while(i < bytes.length)
+ {
+ if( (// ASCII
+ bytes[i] == 0x09 ||
+ bytes[i] == 0x0A ||
+ bytes[i] == 0x0D ||
+ (0x20 <= bytes[i] && bytes[i] <= 0x7E)
+ )
+ ) {
+ i += 1;
+ continue;
+ }
+
+ if( (// non-overlong 2-byte
+ (0xC2 <= bytes[i] && bytes[i] <= 0xDF) &&
+ (0x80 <= bytes[i+1] && bytes[i+1] <= 0xBF)
+ )
+ ) {
+ i += 2;
+ continue;
+ }
+
+ if( (// excluding overlongs
+ bytes[i] == 0xE0 &&
+ (0xA0 <= bytes[i + 1] && bytes[i + 1] <= 0xBF) &&
+ (0x80 <= bytes[i + 2] && bytes[i + 2] <= 0xBF)
+ ) ||
+ (// straight 3-byte
+ ((0xE1 <= bytes[i] && bytes[i] <= 0xEC) ||
+ bytes[i] == 0xEE ||
+ bytes[i] == 0xEF) &&
+ (0x80 <= bytes[i + 1] && bytes[i+1] <= 0xBF) &&
+ (0x80 <= bytes[i+2] && bytes[i+2] <= 0xBF)
+ ) ||
+ (// excluding surrogates
+ bytes[i] == 0xED &&
+ (0x80 <= bytes[i+1] && bytes[i+1] <= 0x9F) &&
+ (0x80 <= bytes[i+2] && bytes[i+2] <= 0xBF)
+ )
+ ) {
+ i += 3;
+ continue;
+ }
+
+ if( (// planes 1-3
+ bytes[i] == 0xF0 &&
+ (0x90 <= bytes[i + 1] && bytes[i + 1] <= 0xBF) &&
+ (0x80 <= bytes[i + 2] && bytes[i + 2] <= 0xBF) &&
+ (0x80 <= bytes[i + 3] && bytes[i + 3] <= 0xBF)
+ ) ||
+ (// planes 4-15
+ (0xF1 <= bytes[i] && bytes[i] <= 0xF3) &&
+ (0x80 <= bytes[i + 1] && bytes[i + 1] <= 0xBF) &&
+ (0x80 <= bytes[i + 2] && bytes[i + 2] <= 0xBF) &&
+ (0x80 <= bytes[i + 3] && bytes[i + 3] <= 0xBF)
+ ) ||
+ (// plane 16
+ bytes[i] == 0xF4 &&
+ (0x80 <= bytes[i + 1] && bytes[i + 1] <= 0x8F) &&
+ (0x80 <= bytes[i + 2] && bytes[i + 2] <= 0xBF) &&
+ (0x80 <= bytes[i + 3] && bytes[i + 3] <= 0xBF)
+ )
+ ) {
+ i += 4;
+ continue;
+ }
+
+ return false;
+ }
+
+ return true;
+}
diff --git a/node_modules/is-utf8/package.json b/node_modules/is-utf8/package.json
new file mode 100644
index 000000000..3b89ee556
--- /dev/null
+++ b/node_modules/is-utf8/package.json
@@ -0,0 +1,87 @@
+{
+ "_args": [
+ [
+ {
+ "raw": "is-utf8@^0.2.0",
+ "scope": null,
+ "escapedName": "is-utf8",
+ "name": "is-utf8",
+ "rawSpec": "^0.2.0",
+ "spec": ">=0.2.0 <0.3.0",
+ "type": "range"
+ },
+ "/home/dold/repos/taler/wallet-webex/node_modules/strip-bom"
+ ]
+ ],
+ "_from": "is-utf8@>=0.2.0 <0.3.0",
+ "_id": "is-utf8@0.2.1",
+ "_inCache": true,
+ "_location": "/is-utf8",
+ "_nodeVersion": "2.3.4",
+ "_npmUser": {
+ "name": "wayfind",
+ "email": "whyer1@gmail.com"
+ },
+ "_npmVersion": "2.12.1",
+ "_phantomChildren": {},
+ "_requested": {
+ "raw": "is-utf8@^0.2.0",
+ "scope": null,
+ "escapedName": "is-utf8",
+ "name": "is-utf8",
+ "rawSpec": "^0.2.0",
+ "spec": ">=0.2.0 <0.3.0",
+ "type": "range"
+ },
+ "_requiredBy": [
+ "/gulp/strip-bom",
+ "/strip-bom"
+ ],
+ "_resolved": "https://registry.npmjs.org/is-utf8/-/is-utf8-0.2.1.tgz",
+ "_shasum": "4b0da1442104d1b336340e80797e865cf39f7d72",
+ "_shrinkwrap": null,
+ "_spec": "is-utf8@^0.2.0",
+ "_where": "/home/dold/repos/taler/wallet-webex/node_modules/strip-bom",
+ "author": {
+ "name": "wayfind"
+ },
+ "bugs": {
+ "url": "https://github.com/wayfind/is-utf8/issues"
+ },
+ "dependencies": {},
+ "description": "Detect if a buffer is utf8 encoded.",
+ "devDependencies": {},
+ "directories": {},
+ "dist": {
+ "shasum": "4b0da1442104d1b336340e80797e865cf39f7d72",
+ "tarball": "https://registry.npmjs.org/is-utf8/-/is-utf8-0.2.1.tgz"
+ },
+ "files": [
+ "is-utf8.js"
+ ],
+ "gitHead": "709df7202f9c3f93cdc2463b352dd80d8de9ce0b",
+ "homepage": "https://github.com/wayfind/is-utf8#readme",
+ "keywords": [
+ "utf8",
+ "charset"
+ ],
+ "license": "MIT",
+ "main": "is-utf8.js",
+ "maintainers": [
+ {
+ "name": "wayfind",
+ "email": "whyer1@gmail.com"
+ }
+ ],
+ "name": "is-utf8",
+ "optionalDependencies": {},
+ "readme": "ERROR: No README data found!",
+ "repository": {
+ "type": "git",
+ "url": "git+https://github.com/wayfind/is-utf8.git"
+ },
+ "scripts": {
+ "test": "node test.js"
+ },
+ "version": "0.2.1"
+}