https://github.com/mk3008/hankaku
Half-width(hankaku) conversion, half-width(hankaku) character count function
https://github.com/mk3008/hankaku
conversion half-width hankaku string
Last synced: 3 months ago
JSON representation
Half-width(hankaku) conversion, half-width(hankaku) character count function
- Host: GitHub
- URL: https://github.com/mk3008/hankaku
- Owner: mk3008
- License: mit
- Created: 2024-05-01T10:26:42.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-05-09T14:25:33.000Z (about 1 year ago)
- Last Synced: 2024-05-09T15:42:05.770Z (about 1 year ago)
- Topics: conversion, half-width, hankaku, string
- Language: C#
- Homepage:
- Size: 29.3 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Hankaku
半角変換と文字数カウント関数を提供します。## デモンストレーション
```cs
using Hankaku;Console.WriteLine("半角変換したい文字列を入力後、Enterキーを押してください。");
var input = Console.ReadLine();
input ??= string.Empty;Console.WriteLine("入力値 : " + input);
// 半角変換後の文字列を取得
var hankakuText = input.ToHankaku();
Console.WriteLine("半角変換後 : " + hankakuText);// 半角文字数カウント
Console.WriteLine("カウント半角: " + hankakuText.CountHankaku());
```### 結果
```
半角変換したい文字列を入力後、Enterキーを押してください。
ヤマダタロウ
入力値 : ヤマダタロウ
半角変換後 : ヤマダタロウ
カウント半角: 7
```## 機能
- 文字列を半角文字列に変換できます。
- 半角変更できる文字列は英数字、記号(スペース含む)、日本語カナのみです。
- 文字列を半角文字なら1、それ以外を2としてカウントすることができます。
- 文字列を左から半角文字数分だけ切り出しすることができます。残りも文字列の取得もできます。## インストール
[Nugetからインストールできます。](https://www.nuget.org/packages/Hankaku)
```
PM> Install-Package Hankaku
```## 使い方
### ToHankaku メソッド
与えられた文字列内の全角文字を半角文字に変換します。
```cs
public static string ToHankaku(this string text)
```### CountHankaku メソッド
与えられた文字列内の日本語半角文字を1、それ以外を2としてカウントします。
```cs
public static int CountHankaku(this string text)
```### LeftHankaku メソッド
文字列を左から半角文字数分切り出します。
```cs
public static string LeftHankaku(this string text, int hankakuCount)
```文字列を左から半角文字数分切り出し、残った文字列も取得します。
```cs
public static string LeftHankaku(this string text, int hankakuCount, out string remainingText)
```