# gbk-string

> 中文 GBK 编码/解码, 示例：`测试` -> `%B2%E2%CA%D4`

Latest version **0.1.0** (published 2018-03-09) · MIT license · 0 weekly downloads

## Install

```sh
npm install gbk-string
pnpm add gbk-string
yarn add gbk-string
bun add gbk-string
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.0 |
| Published | 2018-03-09 |
| First published | 2018-03-02 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=6 |
| Dependencies | 1 |
| Unpacked size | 4.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 16 |
| Author | zh-rocco |
| Maintainers | dahann |
| Keywords | gbk, string, text, convert, node |

## Links

- npm: https://www.npmjs.com/package/gbk-string
- Repository: https://github.com/zh-rocco/gbk-string
- Homepage: https://github.com/zh-rocco/gbk-string#readme
- Issues: https://github.com/zh-rocco/gbk-string/issues
- npm.io page: https://npm.io/package/gbk-string

## Dependencies (1)

- [iconv-lite](https://npm.io/package/iconv-lite.md) ^0.4.19

## Alternatives

- [@expo/fingerprint](https://npm.io/package/@expo/fingerprint.md) — 6.2M weekly downloads
- [@azure/monitor-opentelemetry-exporter](https://npm.io/package/@azure/monitor-opentelemetry-exporter.md) — 850.0K weekly downloads
- [@azure/monitor-opentelemetry](https://npm.io/package/@azure/monitor-opentelemetry.md) — 624.0K weekly downloads
- [@posthog/ai](https://npm.io/package/@posthog/ai.md) — 423.3K weekly downloads
- [fakefilter](https://npm.io/package/fakefilter.md) — 63.9K weekly downloads

## Recent versions

- 0.1.0 (latest) — 2018-03-09
- 0.0.1 — 2018-03-02

## README

# gbk-string

> GBK 编码/解码<br>
> 示例：`测试文本` -> `%B2%E2%CA%D4%CE%C4%B1%BE`

## 背景

使用 node 爬网站数据时，个别接口需要传入 GBK 编码后的字符串。

## 安装

```
$ npm install gbk-string -S
```

## 使用

此插件仅可运行在 Node 环境下，不支持浏览器环境。

```js
const { encodeGBK, decodeGBK } = require('gbk-string');

encodeGBK('测试文本');
//=> "%B2%E2%CA%D4%CE%C4%B1%BE"

decodeGBK('%B2%E2%CA%D4%CE%C4%B1%BE');
//=> "测试文本"
```

或者：

```js
const gbk = require('gbk-string');

gbk.encodeGBK('测试文本');
//=> "%B2%E2%CA%D4%CE%C4%B1%BE"

gbk.decodeGBK('%B2%E2%CA%D4%CE%C4%B1%BE');
//=> "测试文本"
```

## API

### encodeGBK(text)

#### text

Type: `string`

### decodeGBK(str)

#### str

Type: `string`

## 依赖

* [`iconv-lite`](https://github.com/ashtuchkin/iconv-lite)

## License

MIT © [zh-rocco](https://github.com/zh-rocco)

---
_Source: https://npm.io/package/gbk-string · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
