Hankaku 1.0.3

dotnet add package Hankaku --version 1.0.3
NuGet\Install-Package Hankaku -Version 1.0.3
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Hankaku" Version="1.0.3" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Hankaku --version 1.0.3
#r "nuget: Hankaku, 1.0.3"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Hankaku as a Cake Addin
#addin nuget:?package=Hankaku&version=1.0.3

// Install Hankaku as a Cake Tool
#tool nuget:?package=Hankaku&version=1.0.3

Hankaku

半角変換と文字数カウント関数を提供します。

デモンストレーション

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からインストールできます。

PM> Install-Package Hankaku

使い方

ToHankaku メソッド

与えられた文字列内の全角文字を半角文字に変換します。

public static string ToHankaku(this string text)

CountHankaku メソッド

与えられた文字列内の日本語半角文字を1、それ以外を2としてカウントします。

public static int CountHankaku(this string text)

LeftHankaku メソッド

文字列を左から半角文字数分切り出します。

public static string LeftHankaku(this string text, int hankakuCount)

文字列を左から半角文字数分切り出し、残った文字列も取得します。

public static string LeftHankaku(this string text, int hankakuCount, out string remainingText)
Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net8.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.3 65 5/9/2024
1.0.2 32 5/2/2024
1.0.1 32 5/2/2024
0.0.1 57 5/1/2024