New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

str-util

Package Overview
Dependencies
Maintainers
1
Versions
53
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

str-util

convert full/half width, Chinese/Japanese number, 中日漢字轉換... others util helper

Source
npmnpm
Version
2.3.38
Version published
Maintainers
1
Created
Source

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

Keywords

char

FAQs

Package last updated on 12 Apr 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts