### Install japanese-text-utils Source: https://github.com/dovutuan/japanese-text-utils/blob/master/README.md Install the library using npm, yarn, or pnpm. ```bash npm install japanese-text-utils # or yarn add japanese-text-utils # or pnpm add japanese-text-utils ``` -------------------------------- ### CommonJS Usage Source: https://context7.com/dovutuan/japanese-text-utils/llms.txt Use `require` syntax for importing `toHalfSizeCharacters` and `toFullSizeCharacters` in CommonJS environments. Examples demonstrate bidirectional conversion. ```javascript const { toHalfSizeCharacters, toFullSizeCharacters } = require('japanese-text-utils'); // Convert full-width to half-width console.log(toHalfSizeCharacters('"~ ')); // => '"'~ ' // Convert half-width to full-width console.log(toFullSizeCharacters('"'~ ')); // => '"'~ ' ``` -------------------------------- ### CommonJS Usage Source: https://context7.com/dovutuan/japanese-text-utils/llms.txt Demonstrates how to use the `toHalfSizeCharacters` and `toFullSizeCharacters` functions in a CommonJS environment. ```APIDOC ## CommonJS Usage ### Description For CommonJS environments, the library can be required using the standard require syntax. ### Methods - `toHalfSizeCharacters(input: string): string` - `toFullSizeCharacters(input: string): string` ### Request Example ```javascript const { toHalfSizeCharacters, toFullSizeCharacters } = require('japanese-text-utils'); // Convert full-width to half-width console.log(toHalfSizeCharacters('"~ ')); // => '"'~ ' // Convert half-width to full-width console.log(toFullSizeCharacters('"'~ ')); // => '"~ ' ``` ``` -------------------------------- ### toFullSizeCharacters(str) Source: https://github.com/dovutuan/japanese-text-utils/blob/master/README.md Converts a string from half-width (Hankaku) to full-width (Zenkaku) characters. ```APIDOC ## toFullSizeCharacters(str) ### Description Converts a string from half-width to full-width characters, including Katakana, ASCII letters/digits, punctuation, and spaces. ### Parameters - **str** (string) - Required - The input string to convert. ### Response - **string** - The converted string in full-width format. ``` -------------------------------- ### Default Export Source: https://context7.com/dovutuan/japanese-text-utils/llms.txt The library provides a default export object containing both `toHalfSizeCharacters` and `toFullSizeCharacters` functions. ```APIDOC ## Default Export ### Description The library also provides a default export containing both conversion functions as an object, useful for importing the entire API at once. ### Methods - `toHalfSizeCharacters(input: string): string` - `toFullSizeCharacters(input: string): string` ### Request Example ```typescript import japaneseTextUtils from 'japanese-text-utils'; // Access functions via the default export const halfWidth = japaneseTextUtils.toHalfSizeCharacters('カタカナ'); console.log(halfWidth); // => 'カタカナ' const fullWidth = japaneseTextUtils.toFullSizeCharacters('カタカナ'); console.log(fullWidth); // => 'カタカナ' ``` ``` -------------------------------- ### toHalfSizeCharacters(str) Source: https://github.com/dovutuan/japanese-text-utils/blob/master/README.md Converts a string from full-width (Zenkaku) to half-width (Hankaku) characters. ```APIDOC ## toHalfSizeCharacters(str) ### Description Converts a string from full-width to half-width characters, including Katakana, ASCII letters/digits, punctuation, and spaces. ### Parameters - **str** (string) - Required - The input string to convert. ### Response - **string** - The converted string in half-width format. ``` -------------------------------- ### Default Export Usage (TypeScript) Source: https://context7.com/dovutuan/japanese-text-utils/llms.txt Import all conversion functions at once using the default export. Access functions as properties of the imported object. ```typescript import japaneseTextUtils from 'japanese-text-utils'; // Access functions via the default export const halfWidth = japaneseTextUtils.toHalfSizeCharacters('カタカナ'); console.log(halfWidth); // => 'カタカナ' const fullWidth = japaneseTextUtils.toFullSizeCharacters('カタカナ'); console.log(fullWidth); // => 'カタカナ' ``` -------------------------------- ### Convert to Full-Width Characters (TypeScript) Source: https://context7.com/dovutuan/japanese-text-utils/llms.txt Use `toFullSizeCharacters` to convert half-width Japanese text, ASCII, and punctuation to their full-width equivalents. This function also handles dakuten/handakuten and backslash to Yen sign conversion. ```typescript import { toFullSizeCharacters } from 'japanese-text-utils'; // Convert half-width Katakana to full-width const katakana = toFullSizeCharacters('カタカナ'); console.log(katakana); // => 'カタカナ' // Convert ASCII letters and numbers to full-width const alphanumeric = toFullSizeCharacters('ABC123'); console.log(alphanumeric); // => 'ABC123' // Convert half-width punctuation to full-width const punctuation = toFullSizeCharacters('!$?'); console.log(punctuation); // => '!$?' // Convert spaces to full-width const withSpaces = toFullSizeCharacters('テスト テスト'); console.log(withSpaces); // => 'テスト テスト' // Handle dakuten/handakuten correctly (voiced/semi-voiced sounds) const voiced = toFullSizeCharacters('ヴァ'); console.log(voiced); // => 'ヴァ' // Mixed content with quotes and tildes const mixed = toFullSizeCharacters('カタカナ 123 ABC ~ \"'); console.log(mixed); // => 'カタカナ 123 ABC ~ ¥"' // Backslash to Yen sign const backslash = toFullSizeCharacters('\1000'); console.log(backslash); // => '¥1000' ``` -------------------------------- ### Convert Full-width to Half-width (CommonJS) Source: https://github.com/dovutuan/japanese-text-utils/blob/master/README.md Use `toHalfSizeCharacters` in a CommonJS environment to convert full-width characters to half-width. ```javascript const { toHalfSizeCharacters, toFullSizeCharacters } = require('japanese-text-utils'); console.log(toHalfSizeCharacters('"~ ')); // => '"'~ ' ``` -------------------------------- ### Convert Half-width to Full-width (CommonJS) Source: https://github.com/dovutuan/japanese-text-utils/blob/master/README.md Use `toFullSizeCharacters` in a CommonJS environment to convert half-width characters to full-width. ```javascript const { toHalfSizeCharacters, toFullSizeCharacters } = require('japanese-text-utils'); console.log(toFullSizeCharacters('"'~ ')); // => '"'~ ' ``` -------------------------------- ### Convert Full-width to Half-width Katakana Source: https://github.com/dovutuan/japanese-text-utils/blob/master/README.md The `toHalfSizeCharacters` function converts full-width Katakana characters, including those with dakuten and handakuten, to their half-width equivalents. ```typescript expect(toHalfSizeCharacters('ガ')).toBe('ガ'); ``` -------------------------------- ### Convert Full-width to Half-width (ES Module/TypeScript) Source: https://github.com/dovutuan/japanese-text-utils/blob/master/README.md Use `toHalfSizeCharacters` to convert a string from full-width to half-width characters. This includes Katakana, ASCII, spaces, and symbols. ```typescript import { toHalfSizeCharacters, toFullSizeCharacters } from 'japanese-text-utils'; console.log(toHalfSizeCharacters('ガラス-17個「テスト」')); // => 'ガラス-17個「テスト」' ``` -------------------------------- ### Convert Half-width to Full-width Katakana Source: https://github.com/dovutuan/japanese-text-utils/blob/master/README.md The `toFullSizeCharacters` function converts half-width Katakana characters, including those with dakuten and handakuten, to their full-width equivalents. ```typescript expect(toFullSizeCharacters('ヴ')).toBe('ヴ'); ``` -------------------------------- ### Convert Half-width to Full-width (ES Module/TypeScript) Source: https://github.com/dovutuan/japanese-text-utils/blob/master/README.md Use `toFullSizeCharacters` to convert a string from half-width to full-width characters. This includes Katakana, ASCII, spaces, and symbols. ```typescript import { toHalfSizeCharacters, toFullSizeCharacters } from 'japanese-text-utils'; console.log(toFullSizeCharacters('カタカナ 123 ABC ~ \"')); // => 'カタカナ 123 ABC ~ ¥"' ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.