Socket
Socket
Sign inDemoInstall

has-unicode

Package Overview
Dependencies
0
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Protect your apps from supply chain attacks

Install

has-unicode

Try to guess if your terminal supports unicode

    2.0.1latest
    GitHub
    npm

Version published
Maintainers
1
Weekly downloads
12,425,519
decreased by-13.89%

Weekly downloads

Package description

What is has-unicode?

The has-unicode npm package is used to determine if the process environment supports Unicode. This can be useful for applications that need to know whether they can safely output Unicode characters or should fall back to ASCII representations.

What are has-unicode's main functionalities?

Check for Unicode support

This feature allows you to check if the current process environment supports Unicode. The function returns a boolean value.

var hasUnicode = require('has-unicode');
console.log(hasUnicode()); // Outputs: true or false

Other packages similar to has-unicode

Readme

Source

has-unicode

Try to guess if your terminal supports unicode

var hasUnicode = require("has-unicode")

if (hasUnicode()) {
  // the terminal probably has unicode support
}
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.

Keywords

FAQs

Last updated on 23 Jun 2016

Did you know?

Socket installs a GitHub app to automatically flag issues on every pull request and report the health of your dependencies. Find out what is inside your node modules and prevent malicious activity before you update the dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc