
Security News
Maven Central Adds Sigstore Signature Validation
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.
has-unicode
Advanced tools
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.
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
The supports-color package is used to check if the current environment supports color. While it does not check for Unicode support specifically, it is similar in the sense that it checks for a specific type of terminal capability.
The is-utf8 package is used to check if a given buffer is UTF-8 encoded. Unlike has-unicode, which checks the environment's capability, is-utf8 checks the encoding of data.
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
}
})
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.
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.
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.
FAQs
Try to guess if your terminal supports unicode
The npm package has-unicode receives a total of 8,082,718 weekly downloads. As such, has-unicode popularity was classified as popular.
We found that has-unicode demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.
Security News
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.