Skip to content

Instantly share code, notes, and snippets.

@sin-tanaka
Created August 2, 2019 04:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sin-tanaka/c3e84c8fec9fde800f5a302891882f3d to your computer and use it in GitHub Desktop.
Save sin-tanaka/c3e84c8fec9fde800f5a302891882f3d to your computer and use it in GitHub Desktop.
// 参考: https://qiita.com/yamikoo@github/items/5dbcc77b267a549bdbae
export function zenkakuToHankaku(str: string): string {
return str.replace(/[A-Za-z0-9]/g, (s) => {
return String.fromCharCode(s.charCodeAt(0) - 0xFEE0);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment