3.0.2 • Published 1 year ago

str-util v3.0.2

Weekly downloads
2,149
License
ISC
Repository
github
Last release
1 year ago

str-util

convert full/half width, Chinese/Japanese number ... others util helper

npm i str-util

Usage

import * as StrUtil from 'str-util';

See more at test / docs

FullHalf

const str = 'THE quick, BROWN\u3000fox.';

StrUtil.toFullWidth(str);
//=> 'THE quick, BROWN fox.'

StrUtil.toHalfWidth(str);
//=> 'THE quick, BROWN fox.'

console.log(StrUtil.toFullEnglish('123abcABCABC123/*-+=-0][’;/.+-*/=-09][\'";/.'));
console.log(StrUtil.toHalfEnglish('123abcABCABC123/*-+=-0][’;/.+-*/=-09][\'";/.'));
console.log(StrUtil.toFullNumber('123abcABCABC123/*-+=-0][’;/.+-*/=-09][\'";/.'));
console.log(StrUtil.toHalfNumber('123abcABCABC123/*-+=-0][’;/.+-*/=-09][\'";/.'));

default

0123456789
0123456789
ABCDEFGHIJKLMNOPQRSTUVWXYZ
ABCDEFGHIJKLMNOPQRSTUVWXYZ
abcdefghijklmnopqrstuvwxyz
abcdefghijklmnopqrstuvwxyz
 

!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~
!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~

漢字 Number

zh2num('千百十七') == 1117
num2zh(1117) == '千百十七'

中日漢字

import { zh2jp } from 'str-util';

let t = '魔物解説 ランク等話 蚀蝕蝕王で触王 冒険者ギルド解説 蚀|蝕战|戦马|馬亚|亞國預中日漢字對照表'

console.log(zh2jp(t));
import * as ZH2JP from 'str-util/lib/han/zh2jp';

// 沒有漢字存在時會直接返回原參數
console.log(ZH2JP.zhs2jp(1));

// http://ncode.syosetu.com/n1745ct/
let t = '魔物解説 ランク等話 蚀蝕蝕王で触王 冒険者ギルド解説 蚀|蝕战|戦马|馬亚|亞國預中日漢字對照表'

console.log(ZH2JP.zh2jp(t));
console.log(ZH2JP.zht2jp(t));
console.log(ZH2JP.zhs2jp(t));

console.log(ZH2JP.zht2zhs(t));
console.log(ZH2JP.zhs2zht(t));

lib

  • ascii-fullwidth-halfwidth-convert
  • string-width
  • chinese-parseint
  • japanese
3.0.2

1 year ago

3.0.1

1 year ago

2.3.41

2 years ago

2.3.40

2 years ago

2.3.39

2 years ago

2.3.38

2 years ago

2.3.37

3 years ago

2.3.36

3 years ago

2.3.35

3 years ago

2.3.34

3 years ago

2.3.31

3 years ago

2.3.33

3 years ago

2.3.28

3 years ago

2.3.27

4 years ago

2.3.26

5 years ago

2.3.24

5 years ago

2.3.25

5 years ago

2.3.23

5 years ago

2.3.22

5 years ago

2.3.21

6 years ago

2.3.20

6 years ago

2.3.19

6 years ago

2.3.18

6 years ago

2.3.17

6 years ago

2.3.16

7 years ago

2.3.15

7 years ago

2.3.14

7 years ago

2.3.13

7 years ago

2.3.12

7 years ago

2.3.10

7 years ago

2.3.9

7 years ago

2.3.8

7 years ago

2.3.7

7 years ago

2.3.6

7 years ago

2.3.5

7 years ago

2.3.4

7 years ago

2.3.3

7 years ago

2.3.2

7 years ago

2.3.1

7 years ago

2.3.0

7 years ago

2.2.1

7 years ago

2.2.0

7 years ago

2.1.2

7 years ago

2.1.1

7 years ago

2.1.0

7 years ago

2.0.0

7 years ago

1.1.2

7 years ago

1.1.1

7 years ago

1.1.0

8 years ago

1.0.3

8 years ago

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago

0.0.2

11 years ago

0.0.1

11 years ago