版博士V2.0程序
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

README.md 1.4 KiB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. has-unicode
  2. ===========
  3. Try to guess if your terminal supports unicode
  4. ```javascript
  5. var hasUnicode = require("has-unicode")
  6. if (hasUnicode()) {
  7. // the terminal probably has unicode support
  8. }
  9. ```
  10. ```javascript
  11. var hasUnicode = require("has-unicode").tryHarder
  12. hasUnicode(function(unicodeSupported) {
  13. if (unicodeSupported) {
  14. // the terminal probably has unicode support
  15. }
  16. })
  17. ```
  18. ## Detecting Unicode
  19. What we actually detect is UTF-8 support, as that's what Node itself supports.
  20. If you have a UTF-16 locale then you won't be detected as unicode capable.
  21. ### Windows
  22. Since at least Windows 7, `cmd` and `powershell` have been unicode capable,
  23. but unfortunately even then it's not guaranteed. In many localizations it
  24. still uses legacy code pages and there's no facility short of running
  25. programs or linking C++ that will let us detect this. As such, we
  26. report any Windows installation as NOT unicode capable, and recommend
  27. that you encourage your users to override this via config.
  28. ### Unix Like Operating Systems
  29. We look at the environment variables `LC_ALL`, `LC_CTYPE`, and `LANG` in
  30. that order. For `LC_ALL` and `LANG`, it looks for `.UTF-8` in the value.
  31. For `LC_CTYPE` it looks to see if the value is `UTF-8`. This is sufficient
  32. for most POSIX systems. While locale data can be put in `/etc/locale.conf`
  33. as well, AFAIK it's always copied into the environment.