Nkf.Net
1.0.1
dotnet add package Nkf.Net --version 1.0.1
NuGet\Install-Package Nkf.Net -Version 1.0.1
<PackageReference Include="Nkf.Net" Version="1.0.1" />
paket add Nkf.Net --version 1.0.1
#r "nuget: Nkf.Net, 1.0.1"
// Install Nkf.Net as a Cake Addin
#addin nuget:?package=Nkf.Net&version=1.0.1
// Install Nkf.Net as a Cake Tool
#tool nuget:?package=Nkf.Net&version=1.0.1
Nkf.Net
ものすごく古い漢字コード変換プログラムである nkf を .NET から簡単に利用するためのライブラリです.
機能
Windows x86/x64 / Linux x64 環境で 動作します。
入力された日本語テキストが JIS SJIS EUC UTF-8 等を 自動的に認識して読み取りする事ができます。
プログラムの中で そのファイルの エンコードを気にする事なく 日本語ファイルを読み込む事ができます。
コード例
事前準備
Nkf.Net
nuget パッケージを追加してください。
ファイルから読み込み
using (var sr = new Nkf.Net.NkfTextReader(fileName))
{
string s = sr.ReadLine();
while(s != null) {
Console.WriteLine(s);
s = sr.ReadLine();
}
}
エンコードを気にせず バイト配列を 日本語に変換します
string s = "漢字テスト";
byte[] bUTF8 = System.Text.Encoding.UTF8.GetBytes(s);
byte[] bSJIS = System.Text.Encoding.GetEncoding("SJIS").GetBytes(s);
byte[] bEUC = System.Text.Encoding.GetEncoding("EUC-JP").GetBytes(s);
// どんなエンコードのバイト配列でも自動認識して文字を取得できます。
Nkf.Net.NkfEncoding enc = new Nkf.Net.NkfEncoding();
string s1 = enc.GetString(bUTF8);
string s2 = enc.GetString(bSJIS);
string s3 = enc.GetString(bEUC);
Console.WriteLine(s1);
Console.WriteLine(s2);
Console.WriteLine(s3);
nkf の機能を直接利用してファイル変換する
// ファイルをUTF8 変換(入力ファイルのエンコードは未指定)
Nkf.Net.WrapNkf.SetNkfOption("-w"); // UTF-8
Nkf.Net.WrapNkf.FileConvert2(inFile, outFile);
ライセンス
This software is released under the MIT License, see LICENSE.txt. このソフトウェアは、MITライセンスのもとで公開されています。
LICENSE.txtをご覧ください。
同梱の nkf32.dll は gzip ライセンスのもと公開されています。
同梱の nkf32.dll はオリジナルの nkf32.dll
http://sourceforge.jp/projects/nkf/
に「マルチスレッド対応」「x86/x64どちらでも動作可能」の機能を追加したバージョンを利用しています。
機能追加版のソース管理URL
Product | Versions 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 was computed. 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. |
.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 | net40 is compatible. net403 was computed. net45 was computed. net451 was computed. net452 was computed. net46 was computed. 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. |
-
.NETFramework 4.8
- No dependencies.
-
.NETStandard 2.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.