Skip to content

Commit

Permalink
docs(readme): update Features and Installation section
Browse files Browse the repository at this point in the history
  • Loading branch information
polygonplanet committed Feb 28, 2024
1 parent 81fde31 commit a5972b0
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
28 changes: 14 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Convert and detect character encoding in JavaScript.
- [Installation](#installation)
* [npm](#npm)
+ [TypeScript](#typescript)
* [browser (standalone)](#browser-standalone)
* [Browser (standalone)](#browser-standalone)
* [CDN](#cdn)
- [Supported encodings](#supported-encodings)
* [About `UNICODE`](#about-unicode)
Expand Down Expand Up @@ -70,45 +70,45 @@ which can then be passed as strings.
encoding.js is published under the package name `encoding-japanese` on npm.

```bash
$ npm install --save encoding-japanese
npm install --save encoding-japanese
```

#### using `import`
#### Using ES6 `import`

```javascript
import Encoding from 'encoding-japanese';
```

#### using `require`
#### Using CommonJS `require`

```javascript
const Encoding = require('encoding-japanese');
```

#### TypeScript

TypeScript type definitions for encoding.js are available at [@types/encoding-japanese](https://www.npmjs.com/package/@types/encoding-japanese) (thanks [@rhysd](https://github.com/rhysd)).
TypeScript type definitions for encoding.js are available at [@types/encoding-japanese](https://www.npmjs.com/package/@types/encoding-japanese) (thanks to [@rhysd](https://github.com/rhysd)).

```bash
$ npm install --save-dev @types/encoding-japanese
npm install --save-dev @types/encoding-japanese
```

### browser (standalone)
### Browser (standalone)

Install from npm or download from the [release list](https://github.com/polygonplanet/encoding.js/tags) and use `encoding.js` or `encoding.min.js` in the package.
\*Please note that if you `git clone`, even the *master* branch may be under development.
To use encoding.js in a browser environment, you can either install it via npm or download it directly from the [release list](https://github.com/polygonplanet/encoding.js/tags).
The package includes both `encoding.js` and `encoding.min.js`.

Note: Cloning the repository via `git clone` might give you access to the *master* (or *main*) branch, which could still be in a development state.

```html
<!-- To include the full version -->
<script src="encoding.js"></script>
```

Or use the minified `encoding.min.js`

```html
<!-- Or, to include the minified version for production -->
<script src="encoding.min.js"></script>
```

When the script is loaded, the object `Encoding` is defined in the global scope (ie `window.Encoding`).
When the script is loaded, the object `Encoding` is defined in the global scope (i.e., `window.Encoding`).

### CDN

Expand Down
2 changes: 1 addition & 1 deletion README_ja.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ JavaScript で文字コードの変換や判定をします。
## 特徴

encoding.js は、文字コードの変換や判定をする JavaScript ライブラリです。
Shift_JIS や EUC-JP、JIS など日本語の文字コードや、 UTF-8UTF-16 などの Unicode に対応しています。
`Shift_JIS``EUC-JP``ISO-2022-JP` など日本語の文字コードや、 `UTF-8``UTF-16` などの Unicode に対応しています。

JavaScript の文字列は内部で UTF-16 コードユニットとして符号化されるため、文字列のままでは他の文字コードを正しく扱えませんが ([参照: ECMAScript® 2019 Language Specification - 6.1.4 The String Type](https://www.ecma-international.org/ecma-262/10.0/index.html#sec-ecmascript-language-types-string-type))、encoding.js では文字列ではなく配列として扱い変換を実現しています。
各文字コードは、例えば `[130, 160]` (UTF-8の「あ」) などの文字コード値を持つ数値の配列として扱います。
Expand Down

0 comments on commit a5972b0

Please sign in to comment.