Mojix
日本語を扱うための様々な機能を提供します
Static Method Summary
| Static Public Methods | ||
| public static |
codePointAt(text: string, index: number): number サロゲートペア対応のコードポイント取得 |
|
| public static |
codePointCount(text: string, beginIndex: number, endIndex: number): number コードポイント換算で文字列数をカウント |
|
| public static |
compareToForDefault(a: any, b: any): number 2つの文字列を比較する関数
|
|
| public static |
compareToForNatural(a: any, b: any): number 2つの文字列を自然順ソートで比較する関数
|
|
| public static |
cutTextForCodePoint(text: string, offset: number, size: number): string 指定したテキストを切り出す
|
|
| public static |
cutTextForWidth(text: string, offset: number, size: number): string 指定したテキストを切り出す
|
|
| public static |
バイナリ配列から文字列にデコードする |
|
| public static |
文字列からバイナリ配列にエンコードする |
|
| public static |
fromCodePoint(codepoint: ...(number|number[])): string コードポイントの数値データを文字列に変換 |
|
| public static |
Windows-31J 上の区点番号から文字列に変換 |
|
| public static |
fromMenKuTen(menkuten: MenKuTen | string): string Shift_JIS-2004 上の面区点番号から文字列に変換 |
|
| public static |
fromUTF16Array(utf16: number[]): string UTF16の配列から文字列に変換 |
|
| public static |
fromUTF32Array(utf32: number[]): string UTF32の配列から文字列に変換 |
|
| public static |
fromUTF8Array(utf8: number[]): string UTF8の配列から文字列に変換 |
|
| public static |
getMojiData(unicode_codepoint: number): MojiData 指定した1つのUTF-32 コードポイントに関して、解析を行い情報を返します |
|
| public static |
指定したテキストの横幅を半角/全角でカウント
|
|
| public static |
toFullWidth(text: string): string 全角に変換 |
|
| public static |
toFullWidthAlphabet(text: string): string アルファベットを全角に変換 |
|
| public static |
toFullWidthAsciiCode(text: string): string 英数記号を全角に変換 |
|
| public static |
toFullWidthKana(text: string): string カタカナを全角に変換 |
|
| public static |
toFullWidthNumber(text: string): string 数値を全角に変換 |
|
| public static |
toFullWidthSpace(text: string): string スペースを全角に変換 |
|
| public static |
toHalfWidth(text: string): string 半角に変換 |
|
| public static |
toHalfWidthAlphabet(text: string): string アルファベットを半角に変換 |
|
| public static |
toHalfWidthAsciiCode(text: string): string 英数記号を半角に変換 |
|
| public static |
toHalfWidthKana(text: string): string カタカナを半角に変換 |
|
| public static |
toHalfWidthNumber(text: string): string 数値を半角に変換 |
|
| public static |
toHalfWidthSpace(text: string): string スペースを半角に変換 |
|
| public static |
toHiragana(text: string): string カタカナをひらがなに変換 |
|
| public static |
toHiraganaFromRomaji(text: string): string ローマ字からひらがなに変換 |
|
| public static |
toKatakana(text: string): string ひらがなをカタカナに変換 |
|
| public static |
toKatakanaFromRomaji(text: string): string ローマ字からカタカナに変換 |
|
| public static |
指定した文字から Windows-31J 上の区点番号に変換
|
|
| public static |
toMenKuTen(text: string): MenKuTen 指定した文字から Shift_JIS-2004 上の面区点番号に変換
|
|
| public static |
toMojiArrayFromString(text: string): number[][] 結合した文字を考慮して文字列を文字の配列に変換する |
|
| public static |
toRomajiFromHiragana(text: string): string ひらがなからローマ字に変換 |
|
| public static |
toRomajiFromKatakana(text: string): string カタカナからローマ字に変換 |
|
| public static |
toStringFromMojiArray(mojiarray: number[][]): string 結合した文字を考慮して文字の配列を文字列に変換する |
|
| public static |
toUTF16Array(text: string): number[] 文字列をUTF16の配列に変換 |
|
| public static |
toUTF32Array(text: string): number[] 文字列をUTF32(コードポイント)の配列に変換 |
|
| public static |
toUTF8Array(text: string): number[] 文字列をUTF8の配列に変換 |
|
Static Public Methods
public static codePointCount(text: string, beginIndex: number, endIndex: number): number source
コードポイント換算で文字列数をカウント
public static compareToForDefault(a: any, b: any): number source
2つの文字列を比較する関数
- sortの引数で利用できます
Params:
| Name | Type | Attribute | Description |
| a | any | 比較元 |
|
| b | any | 比較先 |
public static compareToForNatural(a: any, b: any): number source
2つの文字列を自然順ソートで比較する関数
- sortの引数で利用できます
- 入力引数は文字列化して比較します
Params:
| Name | Type | Attribute | Description |
| a | any | 比較元 |
|
| b | any | 比較先 |
public static cutTextForCodePoint(text: string, offset: number, size: number): string source
指定したテキストを切り出す
- 単位はコードポイントの文字数
- 結合文字, 異体字セレクタ, スキントーン修飾子, タグ文字を考慮しません
public static cutTextForWidth(text: string, offset: number, size: number): string source
指定したテキストを切り出す
- 0幅 ... グラフェムを構成する要素
(結合文字, 異体字セレクタ, スキントーン修飾子, Tag Sequence 構成文字, ZWSP, ZWNJ, ZWJ, WJ) - 1幅 ... ASCII文字, 半角カタカナ, Regional Indicator(単体)
- 2幅 ... 上記以外
public static encode(text: string, charset: string, is_with_bom: boolean): number[] source
文字列からバイナリ配列にエンコードする
public static fromCodePoint(codepoint: ...(number|number[])): string source
コードポイントの数値データを文字列に変換
Params:
| Name | Type | Attribute | Description |
| codepoint | ...(number|number[]) | 変換したいコードポイントの数値配列、又は数値を並べた可変引数 |
public static fromMenKuTen(menkuten: MenKuTen | string): string source
Shift_JIS-2004 上の面区点番号から文字列に変換
public static fromUTF16Array(utf16: number[]): string source
UTF16の配列から文字列に変換
Params:
| Name | Type | Attribute | Description |
| utf16 | number[] | 変換したいテキスト |
public static fromUTF32Array(utf32: number[]): string source
UTF32の配列から文字列に変換
Params:
| Name | Type | Attribute | Description |
| utf32 | number[] | 変換したいテキスト |
public static fromUTF8Array(utf8: number[]): string source
UTF8の配列から文字列に変換
Params:
| Name | Type | Attribute | Description |
| utf8 | number[] | 変換したいテキスト |
public static getMojiData(unicode_codepoint: number): MojiData source
指定した1つのUTF-32 コードポイントに関して、解析を行い情報を返します
Params:
| Name | Type | Attribute | Description |
| unicode_codepoint | number | UTF-32 のコードポイント |
public static getWidth(text: string): number source
指定したテキストの横幅を半角/全角でカウント
- 0幅 ... グラフェムを構成する要素
(結合文字, 異体字セレクタ, スキントーン修飾子, Tag Sequence 構成文字, ZWSP, ZWNJ, ZWJ, WJ) - 1幅 ... ASCII文字, 半角カタカナ, Regional Indicator(単体)
- 2幅 ... 上記以外
Params:
| Name | Type | Attribute | Description |
| text | string | カウントしたいテキスト |
public static toFullWidth(text: string): string source
全角に変換
Params:
| Name | Type | Attribute | Description |
| text | string | 変換したいテキスト |
public static toFullWidthAlphabet(text: string): string source
アルファベットを全角に変換
Params:
| Name | Type | Attribute | Description |
| text | string | 変換したいテキスト |
public static toFullWidthAsciiCode(text: string): string source
英数記号を全角に変換
Params:
| Name | Type | Attribute | Description |
| text | string | 変換したいテキスト |
public static toFullWidthKana(text: string): string source
カタカナを全角に変換
Params:
| Name | Type | Attribute | Description |
| text | string | 変換したいテキスト |
public static toFullWidthNumber(text: string): string source
数値を全角に変換
Params:
| Name | Type | Attribute | Description |
| text | string | 変換したいテキスト |
public static toFullWidthSpace(text: string): string source
スペースを全角に変換
Params:
| Name | Type | Attribute | Description |
| text | string | 変換したいテキスト |
public static toHalfWidth(text: string): string source
半角に変換
Params:
| Name | Type | Attribute | Description |
| text | string | 変換したいテキスト |
public static toHalfWidthAlphabet(text: string): string source
アルファベットを半角に変換
Params:
| Name | Type | Attribute | Description |
| text | string | 変換したいテキスト |
public static toHalfWidthAsciiCode(text: string): string source
英数記号を半角に変換
Params:
| Name | Type | Attribute | Description |
| text | string | 変換したいテキスト |
public static toHalfWidthKana(text: string): string source
カタカナを半角に変換
Params:
| Name | Type | Attribute | Description |
| text | string | 変換したいテキスト |
public static toHalfWidthNumber(text: string): string source
数値を半角に変換
Params:
| Name | Type | Attribute | Description |
| text | string | 変換したいテキスト |
public static toHalfWidthSpace(text: string): string source
スペースを半角に変換
Params:
| Name | Type | Attribute | Description |
| text | string | 変換したいテキスト |
public static toHiragana(text: string): string source
カタカナをひらがなに変換
Params:
| Name | Type | Attribute | Description |
| text | string | 変換したいテキスト |
public static toHiraganaFromRomaji(text: string): string source
ローマ字からひらがなに変換
Params:
| Name | Type | Attribute | Description |
| text | string | 変換したいテキスト |
public static toKatakana(text: string): string source
ひらがなをカタカナに変換
Params:
| Name | Type | Attribute | Description |
| text | string | 変換したいテキスト |
public static toKatakanaFromRomaji(text: string): string source
ローマ字からカタカナに変換
Params:
| Name | Type | Attribute | Description |
| text | string | 変換したいテキスト |
public static toKuTen(text: string): MenKuTen source
指定した文字から Windows-31J 上の区点番号に変換
- 2文字以上を指定した場合は、1文字目のみを変換する
Params:
| Name | Type | Attribute | Description |
| text | string | 変換したいテキスト |
public static toMenKuTen(text: string): MenKuTen source
指定した文字から Shift_JIS-2004 上の面区点番号に変換
- 2文字以上を指定した場合は、1文字目のみを変換する
Params:
| Name | Type | Attribute | Description |
| text | string | 変換したいテキスト |
public static toMojiArrayFromString(text: string): number[][] source
結合した文字を考慮して文字列を文字の配列に変換する
Params:
| Name | Type | Attribute | Description |
| text | string | 変換したいテキスト |
Return:
| number[][] | UTF32(コードポイント)の配列が入った配列 |
public static toRomajiFromHiragana(text: string): string source
ひらがなからローマ字に変換
Params:
| Name | Type | Attribute | Description |
| text | string | 変換したいテキスト |
public static toRomajiFromKatakana(text: string): string source
カタカナからローマ字に変換
Params:
| Name | Type | Attribute | Description |
| text | string | 変換したいテキスト |
public static toStringFromMojiArray(mojiarray: number[][]): string source
結合した文字を考慮して文字の配列を文字列に変換する
Params:
| Name | Type | Attribute | Description |
| mojiarray | number[][] | UTF32(コードポイント)の配列が入った配列 |
public static toUTF16Array(text: string): number[] source
文字列をUTF16の配列に変換
Params:
| Name | Type | Attribute | Description |
| text | string | 変換したいテキスト |
