HalfFullWidth 2.0.0

dotnet add package HalfFullWidth --version 2.0.0
                    
NuGet\Install-Package HalfFullWidth -Version 2.0.0
                    
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="HalfFullWidth" Version="2.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="HalfFullWidth" Version="2.0.0" />
                    
Directory.Packages.props
<PackageReference Include="HalfFullWidth" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add HalfFullWidth --version 2.0.0
                    
#r "nuget: HalfFullWidth, 2.0.0"
                    
#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.
#:package HalfFullWidth@2.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=HalfFullWidth&version=2.0.0
                    
Install as a Cake Addin
#tool nuget:?package=HalfFullWidth&version=2.0.0
                    
Install as a Cake Tool

HalfFullWidth

A .NET library to convert between halfwidth and fullwidth Unicode forms.

Installation

Install the HalfFullWidth package from NuGet.

https://www.nuget.org/packages/HalfFullWidth/

Usage

Import the HalfFullWidth namespace to get access to the extension methods on String and Char:

using HalfFullWidth;
// ...
string fullwidthString = "ABC".ToFullwidthString(); // ABC
string halfwidthString = "ABC".ToHalfwidthString(); // ABC
char fullwidthChar = 'A'.ToFullwidthChar(); // A
char halfwidthChar = 'A'.ToHalfwidthChar(); // A

Or use the static conversion methods explicitly:

string fullwidthString = HalfFullWidth.Convert.ToFullwidthString("ABC"); // ABC
string halfwidthString = HalfFullWidth.Convert.ToHalfwidthString("ABC"); // ABC
char fullwidthChar = HalfFullWidth.Convert.ToFullwidthChar('A'); // A
char halfwidthChar = HalfFullWidth.Convert.ToHalfwidthChar('A'); // A

Supported frameworks

The library targets .NET Standard 2.0 and .NET 8.0+.

Purpose

This library provides conversion between halfwidth and fullwidth Unicode forms, what is not readily available with .NET Core. Thus offering a cross-platform alternative to the native Windows APIs (see Alternatives).

Conversion is useful for situations where you need to handle Unicode text that can be represented in both halfwidth and fullwidth forms, commonly used in Chinese, Japanese and Korean language scripts.

  • Chinese: 全形和半形、「fullwidth」的各地常用別名(全角、全形)、「halfwidth」的各地常用別名(半角、半形)
  • Japanese: 全角と半角、 半角カナ(はんかくカナ)、半角片仮名(はんかくかたかな, Halfwidth Katakana, 半形假名)
  • Korean: 전각 문자와 반각 문자. 전각/반각 모양

For example, in halfwidth kana (半角カナ) the below halfwidth Japanese alphabet would be converted into the below fullwidth representation.

Halfwidth:

   ア a    イ i    ウ u    エ e    オ o
K  カ ka   キ ki   ク ku   ケ ke   コ ko   キャ kya  キュ kyu  キョ kyo
S  サ sa   シ shi  ス su   セ se   ソ so   シャ sha  シュ shu  ショ sho
T  タ ta   チ chi  ツ tsu  テ te   ト to   チャ cha  チュ chu  チョ cho
N  ナ na   ニ ni   ヌ nu   ネ ne   ノ no   ニャ nya  ニュ nyu  ニョ nyo
H  ハ ha   ヒ hi   フ fu   ヘ he   ホ ho   ヒャ hya  ヒュ hyu  ヒョ hyo
M  マ ma   ミ mi   ム mu   メ me   モ mo   ミャ mya  ミュ myu  ミョ myo
Y  ヤ ya          ユ yu          ヨ yo
R  ラ ra   リ ri   ル ru   レ re   ロ ro   リャ rya  リュ ryu  リョ ryo
W  ワ wa
   ン n
G  ガ ga   ギ gi   グ gu   ゲ ge   ゴ go   ギャ gya  ギュ guy  gyo
Z  ザ za   ジ ji   ズ zu   ゼ ze   ゾ zo   ジャ ja   ジュ ju   ジョ jo
D  ダ da   ヂ (ji) ヅ (zu) デ de   ド do
B  バ ba   ビ bi   ブ bu   ベ be   ボ bo   ビャ bya  ビュ byu  byo
P  パ pa   ピ pi   プ pu   ペ pe   ポ po   ピャ pya  ピュ pyu  pyo
F  ファ fa  フィ fi         フェ fe  フォ fo
T  ツァ tsa ティ ti  トゥ tu
W                       ウェ we  ウォ wo

Fullwidth:

   ア a    イ i    ウ u    エ e    オ o
K  カ ka   キ ki   ク ku   ケ ke   コ ko   キャ kya  キュ kyu  キョ kyo
S  サ sa   シ shi  ス su   セ se   ソ so   シャ sha  シュ shu  ショ sho
T  タ ta   チ chi  ツ tsu  テ te   ト to   チャ cha  チュ chu  チョ cho
N  ナ na   ニ ni   ヌ nu   ネ ne   ノ no   ニャ nya  ニュ nyu  ニョ nyo
H  ハ ha   ヒ hi   フ fu   ヘ he   ホ ho   ヒャ hya  ヒュ hyu  ヒョ hyo
M  マ ma   ミ mi   ム mu   メ me   モ mo   ミャ mya  ミュ myu  ミョ myo
Y  ヤ ya          ユ yu          ヨ yo
R  ラ ra   リ ri   ル ru   レ re   ロ ro   リャ rya  リュ ryu  リョ ryo
W  ワ wa
   ン n
G  ガ ga   ギ gi   グ gu   ゲ ge   ゴ go   ギャ gya  ギュ guy  ギョ gyo
Z  ザ za   ジ ji   ズ zu   ゼ ze   ゾ zo   ジャ ja   ジュ ju   ジョ jo
D  ダ da   ヂ (ji) ヅ (zu) デ de   ド do
B  バ ba   ビ bi   ブ bu   ベ be   ボ bo   ビャ bya  ビュ byu  ビョ byo
P  パ pa   ピ pi   プ pu   ペ pe   ポ po   ピャ pya  ピュ pyu  ピョ pyo
F  ファ fa  フィ fi         フェ fe  フォ fo
T  ツァ tsa ティ ti  トゥ tu
W                       ウェ we  ウォ wo

Implementation

The library uses a character mapping based on the code chart of the Halfwidth and Fullwidth Forms Unicode block (U+FF00–FFEF) of The Unicode Standard, Version 13.0.

When converting a String from fullwidth into halfwidth, it takes into account characters using variation sequences (represented as multiple Char in .NET), by removing the variation.

Please note that the library uses Unicode normalization to be able to convert to and from the two representations. Refer to the specific methods for more details.

Alternatives (Windows only)

There are 2 alternatives for .NET using the Windows API (Win32).

  1. P/Invoke to LCMapString and use the LCMAP_FULLWIDTH and LCMAP_HALFWIDTH map flags.
  2. Use Visual Basic's StrConv() function with VbStrConv.Wide or VbStrConv.Narrow conversion arguments, which uses the above P/Invoke method internally, and throws a PlatformNotSupportedException when not on Windows.

Contributing

The source code was developed with the .NET 8+ SDK.

The .sln at the root of the project allows to:

  • Build the project with dotnet build.
  • Run unit tests with dotnet test.
  • Create the NuGet package with dotnet pack.

If you find a problem, please feel free to open an issue or submit a PR. Thanks! 🙏

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  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.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.0

    • No dependencies.
  • 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
2.0.0 64 4/11/2026
1.0.0 1,353,754 9/12/2020