Skip to content

Commit

Permalink
fixed #2 v1.3.1.1 Add .NETStandard1.x(1.3) to targetframework, remove…
Browse files Browse the repository at this point in the history
… [Description]Attribute for that.

And, adjust csproj structure, WebURL, Readme, etc.
  • Loading branch information
hnx8 committed Apr 21, 2018
1 parent a2ab903 commit 63aad81
Show file tree
Hide file tree
Showing 13 changed files with 226 additions and 221 deletions.
168 changes: 86 additions & 82 deletions ReadJEnc_Readme.txt

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DefineConstants>TRACE;DEBUG</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
Expand All @@ -41,6 +41,18 @@
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Compile Include="..\Hnx8.ReadJEnc\CharCode.cs">
<Link>ReadJEnc\CharCode.cs</Link>
</Compile>
<Compile Include="..\Hnx8.ReadJEnc\FileReader.cs">
<Link>ReadJEnc\FileReader.cs</Link>
</Compile>
<Compile Include="..\Hnx8.ReadJEnc\FileType.cs">
<Link>ReadJEnc\FileType.cs</Link>
</Compile>
<Compile Include="..\Hnx8.ReadJEnc\ReadJEnc.cs">
<Link>ReadJEnc\ReadJEnc.cs</Link>
</Compile>
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="SampleForm.cs">
<SubType>Form</SubType>
Expand All @@ -59,15 +71,6 @@
<DependentUpon>SampleForm.cs</DependentUpon>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Hnx8.ReadJEnc\Hnx8.ReadJEnc.csproj">
<Project>{38bf920b-3043-4dc8-a02e-8f279250b800}</Project>
<Name>Hnx8.ReadJEnc</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2013
VisualStudioVersion = 12.0.40629.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Hnx8.ReadJEnc.WinForm.Sample", "Hnx8.ReadJEnc.WinForm.Sample.csproj", "{35F2FD23-805A-4D14-8857-8C8B82039944}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{35F2FD23-805A-4D14-8857-8C8B82039944}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{35F2FD23-805A-4D14-8857-8C8B82039944}.Debug|Any CPU.Build.0 = Debug|Any CPU
{35F2FD23-805A-4D14-8857-8C8B82039944}.Release|Any CPU.ActiveCfg = Release|Any CPU
{35F2FD23-805A-4D14-8857-8C8B82039944}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ReadJEncSample")]
[assembly: AssemblyCopyright("(C) 2014-2017 hnx8(H.Takahashi)")]
[assembly: AssemblyCopyright("(C) 2014-2018 hnx8(H.Takahashi)")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

Expand Down
90 changes: 43 additions & 47 deletions Source/Hnx8.ReadJEnc.WinForm.Sample/SampleForm.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using System.Text;
using System.Windows.Forms;
using System.ComponentModel;

namespace Hnx8.ReadJEnc.Sample
{
Expand All @@ -26,68 +24,66 @@ static void Main(string[] args)
Application.Run(new SampleForm());
}

List<ReadJEnc> list = new List<ReadJEnc>();

public SampleForm()
{
InitializeComponent();

//ReadJEncクラスに定義されているすべての文字コード判別定義をリフレクションで取り出し、コンボボックスに設定する
FieldInfo[] fields = typeof(ReadJEnc).GetFields(System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.Public);
foreach (FieldInfo f in fields)
// ReadJEncクラスに定義されている文字エンコード判別オブジェクトの一覧をコンボボックスに設定する
KeyValuePair<string, ReadJEnc>[] items =
{
ReadJEnc readjenc = (f.GetValue(null) as ReadJEnc);
if (readjenc != null)
{
list.Add(readjenc);
string text = readjenc.CharCode.ToString();
foreach (object description in f.GetCustomAttributes(typeof(DescriptionAttribute), true))
{ //属性Descriptionに定義されている言語名 + そのReadJEncインスタンスで主に対象とする文字コードで表示名を組み立て
text = (description as DescriptionAttribute).Description + " - " + readjenc.CharCode.ToString();
}
selDefault.Items.Add(text);
}
new KeyValuePair<string, ReadJEnc>("日本語", ReadJEnc.JP),
new KeyValuePair<string, ReadJEnc>("欧文(西欧)", ReadJEnc.ANSI),
#if (!JPONLY)
new KeyValuePair<string, ReadJEnc>("繁体字中国語", ReadJEnc.TW),
new KeyValuePair<string, ReadJEnc>("簡体字中国語", ReadJEnc.CN),
new KeyValuePair<string, ReadJEnc>("ハングル", ReadJEnc.KR),

new KeyValuePair<string, ReadJEnc>("中欧東欧言語", ReadJEnc.CP1250),
new KeyValuePair<string, ReadJEnc>("キリル言語", ReadJEnc.CP1251),
new KeyValuePair<string, ReadJEnc>("ギリシャ語", ReadJEnc.CP1253),
new KeyValuePair<string, ReadJEnc>("トルコ語", ReadJEnc.CP1254),
new KeyValuePair<string, ReadJEnc>("ヘブライ語", ReadJEnc.CP1255),
new KeyValuePair<string, ReadJEnc>("アラビア語", ReadJEnc.CP1256),
new KeyValuePair<string, ReadJEnc>("バルト言語", ReadJEnc.CP1257),
new KeyValuePair<string, ReadJEnc>("ベトナム語", ReadJEnc.CP1258),
new KeyValuePair<string, ReadJEnc>("タイ語", ReadJEnc.TIS620),
#endif
};
foreach (KeyValuePair<string, ReadJEnc> item in items)
{
selDefault.Items.Add(item);
}
//ReadJEnc[] list =
//{
// ReadJEnc.JP,
// ReadJEnc.TW,
// ReadJEnc.CN,
// ReadJEnc.KR,
// ReadJEnc.ANSI,
//};
//selDefault.Items.AddRange(list.ToArray());
selDefault.SelectedIndex = 0;

}

private void button1_Click(object sender, EventArgs e)
{
//連続読み出しの最大許容ファイルサイズ指定値
// 連続読み出しの最大許容ファイルサイズ指定値
int maxFileSize = (int)nmuMaxSize.Value;

string path = txtPath.Text;
ReadJEnc readJEnc = ((KeyValuePair<String, ReadJEnc>)selDefault.SelectedItem).Value;
if (File.Exists(path))
{ //ファイル指定:単一ファイル読み出しの実行例
{ // ファイル指定:単一ファイル読み出しの実行例
System.IO.FileInfo file = new FileInfo(path);
using (FileReader reader = new FileReader(file))
{
//コンボボックス選択どおりの文字コード判別オブジェクトで判別
reader.ReadJEnc = list[selDefault.SelectedIndex]; // (ReadJEnc)selDefault.SelectedItem;
//判別結果の文字コードは、Readメソッドの戻り値で把握できます
{
// コンボボックス選択どおりの文字エンコード判別オブジェクトで判別
reader.ReadJEnc = readJEnc;
// 判別結果の文字エンコードは、Readメソッドの戻り値で把握できます
CharCode c = reader.Read(file);
//戻り値の型からファイルの大まかな種類が判定できます、
// 戻り値の型からファイルの大まかな種類が判定できます、
string type =
(c is CharCode.Text ? "Text:"
: c is FileType.Bin ? "Binary:"
: c is FileType.Image ? "Image:"
: "");
//戻り値のNameプロパティから文字コード名を取得できます
// 戻り値のNameプロパティから文字コード名を取得できます
string name = c.Name;
//戻り値のGetEncoding()メソッドで、エンコーディングを取得できます
// 戻り値のGetEncoding()メソッドで、エンコーディングを取得できます
System.Text.Encoding enc = c.GetEncoding();
//実際に読み出したテキストは、Textプロパティから取得できます
//(非テキストファイルの場合は、nullが設定されます)
// 実際に読み出したテキストは、Textプロパティから取得できます
// (非テキストファイルの場合は、nullが設定されます)
string text = reader.Text;

txtResult.Text =
Expand All @@ -98,15 +94,15 @@ private void button1_Click(object sender, EventArgs e)
}
}
else if (Directory.Exists(path))
{ //ディレクトリ指定:複数ファイル連続読み出しの実行例
{ // ディレクトリ指定:複数ファイル連続読み出しの実行例
txtResult.Text = "一括判定中。。。";
txtResult.Refresh();
//最大許容ファイルサイズ指定でオブジェクトを作成する
// 最大許容ファイルサイズ指定でオブジェクトを作成する
using (FileReader reader = new FileReader(maxFileSize))
{
//コンボボックス選択どおりの文字コード判別オブジェクトで判別
reader.ReadJEnc = list[selDefault.SelectedIndex]; // (ReadJEnc)selDefault.SelectedItem;
//ディレクトリ再帰調査
{
// コンボボックス選択どおりの文字エンコード判別オブジェクトで判別
reader.ReadJEnc = readJEnc;
// ディレクトリ再帰調査
DirectoryInfo dir = new DirectoryInfo(path);
rootDir = dir.FullName.TrimEnd('\\') + @"\";
txtResult.Text = getFiles(reader, dir);
Expand All @@ -127,7 +123,7 @@ private string getFiles(FileReader reader, DirectoryInfo dir)
try
{
foreach (FileInfo f in dir.GetFiles())
{ //各ファイルの文字コード判別のみ実施し、StringBuilderに結果をタブ区切りで詰め込む
{ // 各ファイルの文字エンコード判別のみ実施し、StringBuilderに結果をタブ区切りで詰め込む
CharCode c = reader.Read(f);
sb.Append((f.DirectoryName + @"\").Substring(rootDir.Length));
sb.Append("\t");
Expand All @@ -137,7 +133,7 @@ private string getFiles(FileReader reader, DirectoryInfo dir)
sb.AppendLine();
}
foreach (DirectoryInfo d in dir.GetDirectories())
{ //サブフォルダについて再帰
{ // サブフォルダについて再帰
sb.Append(getFiles(reader, d));
}
}
Expand Down
6 changes: 0 additions & 6 deletions Source/Hnx8.ReadJEnc.WinForm.Sample/app.config

This file was deleted.

6 changes: 3 additions & 3 deletions Source/Hnx8.ReadJEnc/CharCode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ namespace Hnx8.ReadJEnc
public abstract class CharCode
{ ////////////////////////////////////////////////////////////////////////
// <CharCode.cs> ReadJEnc 文字コード種類定義(Rev.20170821)
// Copyright (C) 2014-2017 hnx8(H.Takahashi)
// http://hp.vector.co.jp/authors/VA055804/
// Copyright (C) 2014-2018 hnx8(H.Takahashi)
// https://github.com/hnx8/ReadJEnc
//
// Released under the MIT license
// http://opensource.org/licenses/mit-license.php
Expand Down Expand Up @@ -318,4 +318,4 @@ public override string GetString(byte[] bytes, int len)
}
#endregion
}
}
}
8 changes: 5 additions & 3 deletions Source/Hnx8.ReadJEnc/FileReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ namespace Hnx8.ReadJEnc
public class FileReader : IDisposable
{ ////////////////////////////////////////////////////////////////////////
// <FileReader.cs> ReadJEnc File読出&文字コード自動判別(Rev.20170821)
// Copyright (C) 2014-2017 hnx8(H.Takahashi)
// http://hp.vector.co.jp/authors/VA055804/
// Copyright (C) 2014-2018 hnx8(H.Takahashi)
// https://github.com/hnx8/ReadJEnc
//
// Released under the MIT license
// http://opensource.org/licenses/mit-license.php
Expand All @@ -30,11 +30,13 @@ public FileReader(int len)
Bytes = new byte[len];
}

/// <summary>ファイル読み出し用のリソースを解放します。</summary>
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
/// <summary>ファイル読み出し用のリソースを解放します。</summary>
protected virtual void Dispose(bool disposing)
{
if (disposing)
Expand Down Expand Up @@ -130,4 +132,4 @@ protected virtual CharCode GetPreamble(long len)
}
#endregion
}
}
}
6 changes: 3 additions & 3 deletions Source/Hnx8.ReadJEnc/FileType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
public class FileType : CharCode
{ ////////////////////////////////////////////////////////////////////////
// <FileType.cs> ReadJEnc ファイル種類定義(Rev.20170821)
// Copyright (C) 2014-2017 hnx8(H.Takahashi)
// http://hp.vector.co.jp/authors/VA055804/
// Copyright (C) 2014-2018 hnx8(H.Takahashi)
// https://github.com/hnx8/ReadJEnc
//
// Released under the MIT license
// http://opensource.org/licenses/mit-license.php
Expand Down Expand Up @@ -113,4 +113,4 @@ internal Image(string Name, params byte[] Bytes) : base(Name, 0, Bytes) { }
}
#endregion
}
}
}
30 changes: 20 additions & 10 deletions Source/Hnx8.ReadJEnc/Hnx8.ReadJEnc.csproj
Original file line number Diff line number Diff line change
@@ -1,29 +1,39 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Version>1.3.1.0</Version>
<FileVersion>1.3.1.0</FileVersion>
<Version>1.3.1.1</Version>
<FileVersion>1.3.1.1</FileVersion>
<Authors>hnx8 (H.Takahashi)</Authors>
<Product>ReadJEnc</Product>
<Title>ReadJEnc - Character code automatic discrimination library</Title>
<Description>ReadJEnc C#(.NET) File Character Code Type Automatic Determination Library</Description>
<Product>ReadJEnc 文字エンコード自動判別ライブラリ</Product>
<Title>ReadJEnc - Character code automatic determination library(文字エンコード自動判別ライブラリ)</Title>
<Description>ReadJEnc C#(.NET) File Character Code Type Automatic Determination Library.
日本語あるいは他言語のテキストファイル(またはbyte配列)の内容を解析し、文字エンコーディングを判定してテキスト内容を取り出すライブラリです。
</Description>
<Copyright>Copyright (C) 2014-2018 hnx8 (H.Takahashi)</Copyright>
</PropertyGroup>

<!-- nuspec details -->
<PropertyGroup>
<PackageId>Hnx8.ReadJEnc</PackageId>
<PackageVersion>1.3.1.0</PackageVersion>
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
<PackageId>ReadJEnc</PackageId>
<PackageVersion>1.3.1.1</PackageVersion>
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
<PackageTags>textfile encoding ja-encoding autodetect-encoding</PackageTags>
<PackageLicenseUrl>http://hp.vector.co.jp/authors/VA055804/HNXgrep/ReadJEnc_Readme.txt</PackageLicenseUrl>
<PackageLicenseUrl>https://github.com/hnx8/ReadJEnc/blob/master/LICENSE</PackageLicenseUrl>
<PackageProjectUrl>https://github.com/hnx8/ReadJEnc</PackageProjectUrl>
<PackageIconUrl>https://www.nuget.org/Content/gallery/img/default-package-icon.svg</PackageIconUrl>
<PackageReleaseNotes>https://github.com/hnx8/ReadJEnc#readme
English Version -&gt; https://github.com/hnx8/ReadJEnc/blob/master/README.en.md#readme</PackageReleaseNotes>
</PropertyGroup>

<PropertyGroup>
<TargetFrameworks>netcoreapp2.0;netstandard2.0;net20;net35;net40;net45;net46;net461</TargetFrameworks>
<TargetFrameworks>netcoreapp2.0;netstandard2.0;netstandard1.3;net20;net35;net40;net45;net46;net47;</TargetFrameworks>
<AssemblyName>Hnx8.ReadJEnc</AssemblyName>
<RootNamespace>Hnx8.ReadJEnc</RootNamespace>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)'=='Release'">
<DocumentationFile>bin\Release\netcoreapp2.0\Hnx8.ReadJEnc.xml</DocumentationFile>
<DebugType>none</DebugType>
<DebugSymbols>false</DebugSymbols>
</PropertyGroup>

</Project>
25 changes: 25 additions & 0 deletions Source/Hnx8.ReadJEnc/Hnx8.ReadJEnc.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.27428.2037
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Hnx8.ReadJEnc", "Hnx8.ReadJEnc.csproj", "{C577E01D-58B3-4A9C-A189-803C225986A8}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{C577E01D-58B3-4A9C-A189-803C225986A8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C577E01D-58B3-4A9C-A189-803C225986A8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C577E01D-58B3-4A9C-A189-803C225986A8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C577E01D-58B3-4A9C-A189-803C225986A8}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {08D03B45-026A-4D22-AD57-FDB84DFF8108}
EndGlobalSection
EndGlobal
Loading

0 comments on commit 63aad81

Please sign in to comment.