pax_global_header00006660000000000000000000000064127330570730014521gustar00rootroot0000000000000052 comment=0a05df154e8d89a7fb9798da60b68c78c2df6646 has-unicode-2.0.1/000077500000000000000000000000001273305707300137205ustar00rootroot00000000000000has-unicode-2.0.1/.gitignore000066400000000000000000000011471273305707300157130ustar00rootroot00000000000000# Logs logs *.log # Runtime data pids *.pid *.seed # Directory for instrumented libs generated by jscoverage/JSCover lib-cov # Coverage directory used by tools like istanbul coverage # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) .grunt # Compiled binary addons (http://nodejs.org/api/addons.html) build/Release # Dependency directory # Commenting this out is preferred by some people, see # https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git- node_modules # Users Environment Variables .lock-wscript # Editor temp files *~ .#* has-unicode-2.0.1/LICENSE000066400000000000000000000013601273305707300147250ustar00rootroot00000000000000Copyright (c) 2014, Rebecca Turner Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. has-unicode-2.0.1/README.md000066400000000000000000000025541273305707300152050ustar00rootroot00000000000000has-unicode =========== Try to guess if your terminal supports unicode ```javascript var hasUnicode = require("has-unicode") if (hasUnicode()) { // the terminal probably has unicode support } ``` ```javascript var hasUnicode = require("has-unicode").tryHarder hasUnicode(function(unicodeSupported) { if (unicodeSupported) { // the terminal probably has unicode support } }) ``` ## Detecting Unicode What we actually detect is UTF-8 support, as that's what Node itself supports. If you have a UTF-16 locale then you won't be detected as unicode capable. ### Windows Since at least Windows 7, `cmd` and `powershell` have been unicode capable, but unfortunately even then it's not guaranteed. In many localizations it still uses legacy code pages and there's no facility short of running programs or linking C++ that will let us detect this. As such, we report any Windows installation as NOT unicode capable, and recommend that you encourage your users to override this via config. ### Unix Like Operating Systems We look at the environment variables `LC_ALL`, `LC_CTYPE`, and `LANG` in that order. For `LC_ALL` and `LANG`, it looks for `.UTF-8` in the value. For `LC_CTYPE` it looks to see if the value is `UTF-8`. This is sufficient for most POSIX systems. While locale data can be put in `/etc/locale.conf` as well, AFAIK it's always copied into the environment. has-unicode-2.0.1/index.js000066400000000000000000000012211273305707300153610ustar00rootroot00000000000000"use strict" var os = require("os") var hasUnicode = module.exports = function () { // Recent Win32 platforms (>XP) CAN support unicode in the console but // don't have to, and in non-english locales often use traditional local // code pages. There's no way, short of windows system calls or execing // the chcp command line program to figure this out. As such, we default // this to false and encourage your users to override it via config if // appropriate. if (os.type() == "Windows_NT") { return false } var isUTF8 = /UTF-?8$/i var ctype = process.env.LC_ALL || process.env.LC_CTYPE || process.env.LANG return isUTF8.test(ctype) } has-unicode-2.0.1/package.json000066400000000000000000000011771273305707300162140ustar00rootroot00000000000000{ "name": "has-unicode", "version": "2.0.1", "description": "Try to guess if your terminal supports unicode", "main": "index.js", "scripts": { "test": "tap test/*.js" }, "repository": { "type": "git", "url": "https://github.com/iarna/has-unicode" }, "keywords": [ "unicode", "terminal" ], "files": [ "index.js" ], "author": "Rebecca Turner ", "license": "ISC", "bugs": { "url": "https://github.com/iarna/has-unicode/issues" }, "homepage": "https://github.com/iarna/has-unicode", "devDependencies": { "require-inject": "^1.3.0", "tap": "^2.3.1" } } has-unicode-2.0.1/test/000077500000000000000000000000001273305707300146775ustar00rootroot00000000000000has-unicode-2.0.1/test/index.js000066400000000000000000000027721273305707300163540ustar00rootroot00000000000000"use strict" var test = require("tap").test var requireInject = require("require-inject") test("Windows", function (t) { t.plan(1) var hasUnicode = requireInject("../index.js", { os: { type: function () { return "Windows_NT" } } }) t.is(hasUnicode(), false, "Windows is assumed NOT to be unicode aware") }) test("Unix Env", function (t) { var hasUnicode = requireInject("../index.js", { os: { type: function () { return "Linux" } }, child_process: { exec: function (cmd,cb) { cb(new Error("not available")) } } }) function test3(LC_ALL, LC_CTYPE, LANG, expected, comment) { var env = process.env if (LC_ALL) env.LC_ALL = LC_ALL; else delete env.LC_ALL if (LC_CTYPE) env.LC_CTYPE = LC_CTYPE; else delete env.LC_CTYPE if (LANG) env.LANG = LANG; else delete env.LANG t.is(hasUnicode(), expected, comment) } test3(null, null, "en_US.UTF-8", true, "Linux with a UTF-8 language") test3("en_US.UTF-8", null, null, true, "Linux with UTF-8 locale") test3(null, null, null, false, "Linux with no locale setting at all") test3(null, "en_US.UTF-8", null, true, "Linux with UTF-8 in character type") test3(null, "UTF-8", null, true, "Linux with UTF-8 as character type") test3("C", "en_US.UTF-8", "en_US.UTF-8", false, "LC_ALL overrides") test3(null, "en_US", "en_US.UTF-8", false, "LC_CTYPE overrides LANG") test3(null, null, null, false, "Linux with no locale setting at all") test3(null, null, "de_DE.utf8", true, "Linux with utf8 language") t.end() })