https://github.com/gucong3000/stdcp
An effort to encapsulate the output code page used by the console of current process.
https://github.com/gucong3000/stdcp
chcp code-page getconsoleoutputcp setconsoleoutputcp
Last synced: about 1 year ago
JSON representation
An effort to encapsulate the output code page used by the console of current process.
- Host: GitHub
- URL: https://github.com/gucong3000/stdcp
- Owner: gucong3000
- License: mit
- Created: 2018-12-09T05:12:48.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-12-21T08:14:11.000Z (over 7 years ago)
- Last Synced: 2025-02-22T20:03:14.274Z (over 1 year ago)
- Topics: chcp, code-page, getconsoleoutputcp, setconsoleoutputcp
- Language: JavaScript
- Homepage:
- Size: 15.6 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
stdcp
====
[](https://www.npmjs.com/package/stdcp)
[](https://ci.appveyor.com/project/gucong3000/stdcp)
[](https://codecov.io/gh/gucong3000/stdcp)
[](https://david-dm.org/gucong3000/stdcp)
An effort to encapsulate the output code page used by the console of current process.
This library provides native bindings for Windows APIs:
- [GetACP](https://docs.microsoft.com/windows/desktop/api/winnls/nf-winnls-getacp)
- [GetConsoleOutputCP](https://docs.microsoft.com/windows/console/getconsoleoutputcp)
- [SetConsoleOutputCP](https://docs.microsoft.com/windows/console/setconsoleoutputcp)
## Use Case
```javascript
const stdcp = require("stdcp");
// Asynchronously APIs
(async () => {
console.log(await stdcp.get(true)) // Get current Windows code page.
console.log(await stdcp.get()) // Get code page for current console.
await stdcp.set(65001); // Set code page for current console.
})();
// Synchronously APIs
(() => {
console.log(stdcp.getSync(true)) // Get current Windows code page.
console.log(stdcp.getSync()) // Get code page for current console.
stdcp.setSync(65001) // Set code page for current console.
})();
```
## Related
- [Code Page Identifiers](https://docs.microsoft.com/windows/desktop/intl/code-page-identifiers)
- [chcp](https://docs.microsoft.com/windows-server/administration/windows-commands/chcp)