├── .gitattributes ├── .github └── workflows │ ├── PublishNuget.yml │ └── dotnetcore.yml ├── .gitignore ├── Directory.Build.props ├── EncodingNormalior.WPF ├── App.xaml ├── App.xaml.cs ├── AssemblyInfo.cs ├── EncodingNormalior.WPF.csproj ├── MainWindow.xaml ├── MainWindow.xaml.cs ├── Model │ ├── EncodingConverter.cs │ ├── EncodingScrutatorFile.cs │ ├── EncodingScrutatorFolder.cs │ ├── EncodingScrutatorFolderFile.cs │ ├── EncodingScrutatorProgress.cs │ ├── IEncodingConverter.cs │ ├── IEncodingScrutatorFile.cs │ ├── Solution.cs │ ├── Utf8WithoutBomEncodingConverter.cs │ └── WriteFolderEncoding.cs ├── Resources │ ├── ConvertFileEncoding.png │ ├── EncodingNormalizer.png │ ├── EncodingNormalizerPackage.ico │ ├── Icon.ico │ ├── Logo.png │ ├── QQ截图20170114120751.png │ ├── QQ截图2017011412075116.png │ ├── code_711px_1157693_easyicon.net.png │ └── code_711px_16_easyicon.net.png ├── View │ ├── Button.xaml │ ├── Color.xaml │ ├── ConformPage.xaml │ ├── ConformPage.xaml.cs │ ├── ConvertDashPercent.cs │ ├── ConvertEncodingStr.cs │ ├── ConvertFileEncodingPage.xaml │ ├── ConvertFileEncodingPage.xaml.cs │ ├── ConvertFractionStr.cs │ ├── DefinitionPage.xaml │ ├── DefinitionPage.xaml.cs │ └── Icon.xaml └── ViewModel │ ├── Account.cs │ ├── ConformModel.cs │ ├── ConvertFileEncodingModel.cs │ ├── DefinitionModel.cs │ └── NotifyProperty.cs ├── EncodingNormalior.sln ├── EncodingNormalior.sln.DotSettings ├── EncodingNormalior ├── App.config ├── ArgumentCommadnException.cs ├── CommandLineArgument.cs ├── CommandLineArgumentParser.cs ├── EncodingNormalior.csproj ├── EncodingNormaliorException.cs ├── Key.snk ├── Model │ ├── EncodingNormaliorContext.cs │ ├── EncodingScrutator.cs │ ├── EncodingScrutatorFile.cs │ ├── EncodingScrutatorFileStorage.cs │ ├── EncodingScrutatorFolder.cs │ ├── ISetting.cs │ ├── IncludeFileSetting.cs │ ├── InspectEncoding.cs │ ├── InspectFileWhiteListSetting.cs │ ├── SitpulationEncodingSetting.cs │ └── WildcardRegexString.cs ├── Program.cs ├── Properties │ └── Annotations.cs ├── README.md ├── dotnetCampus.EncodingNormalior.csproj ├── ico.ico ├── ico.png └── textFile │ ├── Ascii.txt │ ├── Endian.txt │ ├── GBK 1.txt │ ├── GBK 2.txt │ ├── GBK 3.txt │ ├── GBK.txt │ ├── US-ASCII.txt │ ├── UTF7.txt │ ├── UTF8sig.txt │ ├── Unicode (Big-Endian).txt │ ├── Unicode (UTF-8).txt │ ├── Unicode.txt │ ├── utf7 1.txt │ ├── utf7 2.txt │ ├── utf8 无签名1.txt │ ├── utf8.txt │ └── 简体中文(GB2312).txt ├── EncodingNormalizer.UnitTest ├── App.config ├── ArgTest.cs ├── EncodingNormalizer.UnitTest.csproj ├── IncludeFileSettingTest.cs ├── InspectEncoding.cs ├── InspectFileWhiteListSettingTest.cs ├── Program.cs ├── Properties │ └── AssemblyInfo.cs └── textFile │ ├── Ascii.txt │ ├── Endian.txt │ ├── GBK 1.txt │ ├── GBK 2.txt │ ├── GBK 3.txt │ ├── GBK.txt │ ├── US-ASCII.txt │ ├── UTF7.txt │ ├── UTF8sig.txt │ ├── Unicode (Big-Endian).txt │ ├── Unicode (UTF-8).txt │ ├── Unicode.txt │ ├── utf7 1.txt │ ├── utf7 2.txt │ ├── utf8 无签名1.txt │ ├── utf8.txt │ └── 简体中文(GB2312).txt ├── EncodingNormalizerVsix ├── EncodingNormalizer.cs ├── EncodingNormalizerVsixForVS2022.csproj ├── EncodingNormalizerVsixPackage.cs ├── EncodingNormalizerVsixPackage.vsct ├── GuidStrings.cs ├── Properties │ └── AssemblyInfo.cs ├── Resources │ ├── ConvertFileEncoding.png │ ├── EncodingNormalizer.png │ ├── EncodingNormalizerPackage.ico │ ├── Icon.ico │ ├── Logo.png │ ├── QQ截图20170114120751.png │ ├── QQ截图2017011412075116.png │ ├── code_711px_1157693_easyicon.net.png │ └── code_711px_16_easyicon.net.png └── source.extension.vsixmanifest ├── EncodingNormalizerVsx ├── DefinitionPage.cs ├── EncodingNormalizer.cs ├── EncodingNormalizerPackage.cs ├── EncodingNormalizerPackage.vsct ├── EncodingNormalizerVsx.csproj ├── GuidStrings.cs ├── Key.snk ├── Properties │ └── AssemblyInfo.cs ├── Resources │ ├── ConvertFileEncoding.png │ ├── EncodingNormalizer.png │ ├── EncodingNormalizerPackage.ico │ ├── Icon.ico │ ├── Logo.png │ ├── QQ截图20170114120751.png │ ├── QQ截图2017011412075116.png │ ├── code_711px_1157693_easyicon.net.png │ └── code_711px_16_easyicon.net.png ├── VSPackage.resx ├── app.config ├── index.html ├── packages.config ├── source.extension.vsixmanifest └── stylesheet.css ├── EncodingUtf8AndGBKDifferentiater ├── EncodingDifferentiater.cs └── EncodingUtf8AndGBKDifferentiater.csproj ├── LICENSE ├── README.md ├── appveyor.yml └── build └── Version.props /.gitattributes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Set default behavior to automatically normalize line endings. 3 | ############################################################################### 4 | * text=auto 5 | 6 | ############################################################################### 7 | # Set default behavior for command prompt diff. 8 | # 9 | # This is need for earlier builds of msysgit that does not have it on by 10 | # default for csharp files. 11 | # Note: This is only used by command line 12 | ############################################################################### 13 | #*.cs diff=csharp 14 | 15 | ############################################################################### 16 | # Set the merge driver for project and solution files 17 | # 18 | # Merging from the command prompt will add diff markers to the files if there 19 | # are conflicts (Merging from VS is not affected by the settings below, in VS 20 | # the diff markers are never inserted). Diff markers may cause the following 21 | # file extensions to fail to load in VS. An alternative would be to treat 22 | # these files as binary and thus will always conflict and require user 23 | # intervention with every merge. To do so, just uncomment the entries below 24 | ############################################################################### 25 | #*.sln merge=binary 26 | #*.csproj merge=binary 27 | #*.vbproj merge=binary 28 | #*.vcxproj merge=binary 29 | #*.vcproj merge=binary 30 | #*.dbproj merge=binary 31 | #*.fsproj merge=binary 32 | #*.lsproj merge=binary 33 | #*.wixproj merge=binary 34 | #*.modelproj merge=binary 35 | #*.sqlproj merge=binary 36 | #*.wwaproj merge=binary 37 | 38 | ############################################################################### 39 | # behavior for image files 40 | # 41 | # image files are treated as binary by default. 42 | ############################################################################### 43 | #*.jpg binary 44 | #*.png binary 45 | #*.gif binary 46 | 47 | ############################################################################### 48 | # diff behavior for common document formats 49 | # 50 | # Convert binary document formats to text before diffing them. This feature 51 | # is only available from the command line. Turn it on by uncommenting the 52 | # entries below. 53 | ############################################################################### 54 | #*.doc diff=astextplain 55 | #*.DOC diff=astextplain 56 | #*.docx diff=astextplain 57 | #*.DOCX diff=astextplain 58 | #*.dot diff=astextplain 59 | #*.DOT diff=astextplain 60 | #*.pdf diff=astextplain 61 | #*.PDF diff=astextplain 62 | #*.rtf diff=astextplain 63 | #*.RTF diff=astextplain 64 | -------------------------------------------------------------------------------- /.github/workflows/PublishNuget.yml: -------------------------------------------------------------------------------- 1 | name: publish nuget 2 | 3 | on: 4 | push: 5 | branches: 6 | - master 7 | 8 | jobs: 9 | build: 10 | 11 | runs-on: windows-latest 12 | 13 | steps: 14 | - uses: actions/checkout@v1 15 | 16 | - name: Build with dotnet 17 | run: dotnet build "EncodingNormalior\dotnetCampus.EncodingNormalior.csproj" --configuration Release 18 | - name: Install Nuget 19 | run: | 20 | $sourceNugetExe = "https://dist.nuget.org/win-x86-commandline/latest/nuget.exe" 21 | $targetNugetExe = "nuget.exe" 22 | Invoke-WebRequest $sourceNugetExe -OutFile $targetNugetExe 23 | - name: Add private GitHub registry to NuGet 24 | run: | 25 | .\nuget sources add -name github -Source https://nuget.pkg.github.com/ORGANIZATION_NAME/index.json -Username ORGANIZATION_NAME -Password ${{ secrets.GITHUB_TOKEN }} 26 | - name: Push generated package to GitHub registry 27 | run: | 28 | .\nuget push .\bin\release\*.nupkg -Source github -SkipDuplicate 29 | .\nuget push .\bin\release\*.nupkg -Source https://api.nuget.org/v3/index.json -SkipDuplicate -ApiKey ${{ secrets.NugetKey }} -NoSymbols 30 | -------------------------------------------------------------------------------- /.github/workflows/dotnetcore.yml: -------------------------------------------------------------------------------- 1 | name: .NET Core 2 | 3 | on: [push] 4 | 5 | jobs: 6 | build: 7 | 8 | runs-on: windows-latest 9 | 10 | steps: 11 | - uses: actions/checkout@v1 12 | 13 | - name: Build with dotnet 14 | run: dotnet build "EncodingNormalior\dotnetCampus.EncodingNormalior.csproj" --configuration Release 15 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | 4 | # User-specific files 5 | *.suo 6 | *.user 7 | *.userosscache 8 | *.sln.docstates 9 | 10 | # User-specific files (MonoDevelop/Xamarin Studio) 11 | *.userprefs 12 | 13 | # Build results 14 | [Dd]ebug/ 15 | [Dd]ebugPublic/ 16 | [Rr]elease/ 17 | [Rr]eleases/ 18 | [Xx]64/ 19 | [Xx]86/ 20 | [Bb]uild/ 21 | bld/ 22 | [Bb]in/ 23 | [Oo]bj/ 24 | 25 | # Visual Studio 2015 cache/options directory 26 | .vs/ 27 | # Uncomment if you have tasks that create the project's static files in wwwroot 28 | #wwwroot/ 29 | 30 | # MSTest test Results 31 | [Tt]est[Rr]esult*/ 32 | [Bb]uild[Ll]og.* 33 | 34 | # NUNIT 35 | *.VisualState.xml 36 | TestResult.xml 37 | 38 | # Build Results of an ATL Project 39 | [Dd]ebugPS/ 40 | [Rr]eleasePS/ 41 | dlldata.c 42 | 43 | # DNX 44 | project.lock.json 45 | artifacts/ 46 | 47 | *_i.c 48 | *_p.c 49 | *_i.h 50 | *.ilk 51 | *.meta 52 | *.obj 53 | *.pch 54 | *.pdb 55 | *.pgc 56 | *.pgd 57 | *.rsp 58 | *.sbr 59 | *.tlb 60 | *.tli 61 | *.tlh 62 | *.tmp 63 | *.tmp_proj 64 | *.log 65 | *.vspscc 66 | *.vssscc 67 | .builds 68 | *.pidb 69 | *.svclog 70 | *.scc 71 | 72 | # Chutzpah Test files 73 | _Chutzpah* 74 | 75 | # Visual C++ cache files 76 | ipch/ 77 | *.aps 78 | *.ncb 79 | *.opendb 80 | *.opensdf 81 | *.sdf 82 | *.cachefile 83 | *.VC.db 84 | 85 | # Visual Studio profiler 86 | *.psess 87 | *.vsp 88 | *.vspx 89 | *.sap 90 | 91 | # TFS 2012 Local Workspace 92 | $tf/ 93 | 94 | # Guidance Automation Toolkit 95 | *.gpState 96 | 97 | # ReSharper is a .NET coding add-in 98 | _ReSharper*/ 99 | *.[Rr]e[Ss]harper 100 | *.DotSettings.user 101 | 102 | # JustCode is a .NET coding add-in 103 | .JustCode 104 | 105 | # TeamCity is a build add-in 106 | _TeamCity* 107 | 108 | # DotCover is a Code Coverage Tool 109 | *.dotCover 110 | 111 | # NCrunch 112 | _NCrunch_* 113 | .*crunch*.local.xml 114 | nCrunchTemp_* 115 | 116 | # MightyMoose 117 | *.mm.* 118 | AutoTest.Net/ 119 | 120 | # Web workbench (sass) 121 | .sass-cache/ 122 | 123 | # Installshield output folder 124 | [Ee]xpress/ 125 | 126 | # DocProject is a documentation generator add-in 127 | DocProject/buildhelp/ 128 | DocProject/Help/*.HxT 129 | DocProject/Help/*.HxC 130 | DocProject/Help/*.hhc 131 | DocProject/Help/*.hhk 132 | DocProject/Help/*.hhp 133 | DocProject/Help/Html2 134 | DocProject/Help/html 135 | 136 | # Click-Once directory 137 | publish/ 138 | 139 | # Publish Web Output 140 | *.[Pp]ublish.xml 141 | *.azurePubxml 142 | 143 | # TODO: Un-comment the next line if you do not want to checkin 144 | # your web deploy settings because they may include unencrypted 145 | # passwords 146 | #*.pubxml 147 | *.publishproj 148 | 149 | # NuGet Packages 150 | *.nupkg 151 | # The packages folder can be ignored because of Package Restore 152 | **/packages/* 153 | # except build/, which is used as an MSBuild target. 154 | !**/packages/build/ 155 | # Uncomment if necessary however generally it will be regenerated when needed 156 | #!**/packages/repositories.config 157 | # NuGet v3's project.json files produces more ignoreable files 158 | *.nuget.props 159 | *.nuget.targets 160 | 161 | # Microsoft Azure Build Output 162 | csx/ 163 | *.build.csdef 164 | 165 | # Microsoft Azure Emulator 166 | ecf/ 167 | rcf/ 168 | 169 | # Windows Store app package directory 170 | AppPackages/ 171 | BundleArtifacts/ 172 | 173 | # Visual Studio cache files 174 | # files ending in .cache can be ignored 175 | *.[Cc]ache 176 | # but keep track of directories ending in .cache 177 | !*.[Cc]ache/ 178 | 179 | # Others 180 | ClientBin/ 181 | [Ss]tyle[Cc]op.* 182 | ~$* 183 | *~ 184 | *.dbmdl 185 | *.dbproj.schemaview 186 | *.pfx 187 | *.publishsettings 188 | node_modules/ 189 | orleans.codegen.cs 190 | 191 | # RIA/Silverlight projects 192 | Generated_Code/ 193 | 194 | # Backup & report files from converting an old project file 195 | # to a newer Visual Studio version. Backup files are not needed, 196 | # because we have git ;-) 197 | _UpgradeReport_Files/ 198 | Backup*/ 199 | UpgradeLog*.XML 200 | UpgradeLog*.htm 201 | 202 | # SQL Server files 203 | *.mdf 204 | *.ldf 205 | 206 | # Business Intelligence projects 207 | *.rdl.data 208 | *.bim.layout 209 | *.bim_*.settings 210 | 211 | # Microsoft Fakes 212 | FakesAssemblies/ 213 | 214 | # GhostDoc plugin setting file 215 | *.GhostDoc.xml 216 | 217 | # Node.js Tools for Visual Studio 218 | .ntvs_analysis.dat 219 | 220 | # Visual Studio 6 build log 221 | *.plg 222 | 223 | # Visual Studio 6 workspace options file 224 | *.opt 225 | 226 | # Visual Studio LightSwitch build output 227 | **/*.HTMLClient/GeneratedArtifacts 228 | **/*.DesktopClient/GeneratedArtifacts 229 | **/*.DesktopClient/ModelManifest.xml 230 | **/*.Server/GeneratedArtifacts 231 | **/*.Server/ModelManifest.xml 232 | _Pvt_Extensions 233 | 234 | # LightSwitch generated files 235 | GeneratedArtifacts/ 236 | ModelManifest.xml 237 | 238 | # Paket dependency manager 239 | .paket/paket.exe 240 | 241 | # FAKE - F# Make 242 | .fake/ 243 | -------------------------------------------------------------------------------- /Directory.Build.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | $(MSBuildThisFileDirectory)bin\$(Configuration) 5 | dotnet-campus 6 | dotnet-campus 7 | latest 8 | false 9 | Copyright (c) 2020 dotnet-campus 10 | https://github.com/dotnet-campus/EncodingNormalior 11 | https://github.com/dotnet-campus/EncodingNormalior 12 | git 13 | dotnet;Encoding;dotnet-tool 14 | MIT 15 | 16 | -------------------------------------------------------------------------------- /EncodingNormalior.WPF/App.xaml: -------------------------------------------------------------------------------- 1 |  6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /EncodingNormalior.WPF/App.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Configuration; 4 | using System.Data; 5 | using System.Linq; 6 | using System.Threading.Tasks; 7 | using System.Windows; 8 | 9 | namespace EncodingNormalior.WPF 10 | { 11 | /// 12 | /// Interaction logic for App.xaml 13 | /// 14 | public partial class App : Application 15 | { 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /EncodingNormalior.WPF/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Windows; 2 | 3 | [assembly: ThemeInfo( 4 | ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located 5 | //(used if a resource is not found in the page, 6 | // or application resource dictionaries) 7 | ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located 8 | //(used if a resource is not found in the page, 9 | // app, or any theme specific resource dictionaries) 10 | )] 11 | -------------------------------------------------------------------------------- /EncodingNormalior.WPF/EncodingNormalior.WPF.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | WinExe 5 | net461 6 | true 7 | true 8 | ..\EncodingNormalizerVsx\Key.snk 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | Always 19 | 20 | 21 | Always 22 | 23 | 24 | Always 25 | 26 | 27 | Always 28 | 29 | 30 | Always 31 | 32 | 33 | 34 | Always 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | Always 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /EncodingNormalior.WPF/MainWindow.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Windows; 3 | using System.Windows.Controls; 4 | 5 | namespace EncodingNormalizerVsx 6 | { 7 | public partial class MainWindow : Window 8 | { 9 | public MainWindow() 10 | { 11 | InitializeComponent(); 12 | //ContentRendered 13 | } 14 | 15 | public new UserControl Content { set; get; } 16 | 17 | private void MinimizeButton_Click(object sender, RoutedEventArgs e) 18 | { 19 | WindowState = WindowState.Minimized; 20 | } 21 | 22 | private void MaximizeButton_OnClick(object sender, RoutedEventArgs e) 23 | { 24 | WindowState = WindowState == WindowState.Maximized ? WindowState.Normal : WindowState.Maximized; 25 | } 26 | 27 | private void CloseButton_Click(object sender, RoutedEventArgs e) 28 | { 29 | Close(); 30 | } 31 | 32 | private void LoadStoryboard_Completed(object sender, EventArgs e) 33 | { 34 | ((Panel)SplashPanel.Parent).Children.Remove(SplashPanel); 35 | SplashPanel = null; 36 | SplashLogo = null; 37 | 38 | Frame.Navigate(Content); 39 | } 40 | } 41 | } -------------------------------------------------------------------------------- /EncodingNormalior.WPF/Model/EncodingConverter.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | using System.Text; 3 | 4 | namespace EncodingNormalizerVsx.Model 5 | { 6 | public class EncodingConverter : IEncodingConverter 7 | { 8 | /// 9 | public EncodingConverter(Encoding encoding) 10 | { 11 | Encoding = encoding; 12 | } 13 | 14 | public string Read(FileInfo file) 15 | { 16 | using (var stream = new StreamReader(file.OpenRead(), Encoding)) 17 | { 18 | return stream.ReadToEnd(); 19 | } 20 | } 21 | 22 | public void Storage(string str, FileInfo file) 23 | { 24 | using (var stream = new StreamWriter(file.Open(FileMode.Create, FileAccess.Write), Encoding)) 25 | { 26 | stream.Write(str); 27 | } 28 | } 29 | 30 | public Encoding Encoding { get; } 31 | 32 | public virtual string EncodingName => Encoding.EncodingName; 33 | } 34 | } -------------------------------------------------------------------------------- /EncodingNormalior.WPF/Model/EncodingScrutatorFile.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | using System.Text; 3 | 4 | namespace EncodingNormalizerVsx.Model 5 | { 6 | public class EncodingScrutatorFile : EncodingScrutatorFolderFile 7 | { 8 | public Encoding Encoding { set; get; } 9 | 10 | public EncodingScrutatorFile(EncodingNormalior.Model.EncodingScrutatorFile encodingScrutatorFile, 11 | EncodingScrutatorFolder parent) : base(encodingScrutatorFile.Name, parent) 12 | { 13 | File = encodingScrutatorFile.File; 14 | Encoding = encodingScrutatorFile.Encoding; 15 | //_encoding = encodingScrutatorFile.Encoding.EncodingName; 16 | } 17 | 18 | //private string _encoding; 19 | 20 | public FileInfo File { set; get; } 21 | ///// 22 | ///// 重写文件编码 23 | ///// 24 | ///// 25 | //public void WriteSitpulationEncoding(Encoding encoding) 26 | //{ 27 | // if (_encoding == System.Text.Encoding.ASCII.EncodingName) 28 | // { 29 | // if (Equals(encoding, System.Text.Encoding.UTF8) || 30 | // Equals(encoding, System.Text.Encoding.GetEncoding("GBK")) || 31 | // Equals(encoding, System.Text.Encoding.ASCII)) //对 ASCII不写入 32 | // { 33 | // return; 34 | // } 35 | // } 36 | // string str; 37 | // using (var stream = new StreamReader(File.OpenRead(), Encoding)) 38 | // { 39 | // str = stream.ReadToEnd(); 40 | // } 41 | // using (var stream = new StreamWriter(new FileStream(File.FullName, FileMode.Create), encoding)) 42 | // { 43 | // stream.Write(str); 44 | // } 45 | //} 46 | 47 | /// 48 | /// 获取全名称 49 | /// 50 | public string GetEncodingScrutatorFileDirectory() 51 | { 52 | var encodingScrutatorFile = this; 53 | var str = new StringBuilder(); 54 | var folder = encodingScrutatorFile.Parent; 55 | str.Append(encodingScrutatorFile.File.Name); 56 | while (folder != null) 57 | { 58 | str.Insert(0, folder.Name + "\\"); 59 | folder = folder.Parent; 60 | } 61 | return str.ToString(); 62 | } 63 | } 64 | } -------------------------------------------------------------------------------- /EncodingNormalior.WPF/Model/EncodingScrutatorFolder.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using EncodingNormalior.Model; 3 | 4 | namespace EncodingNormalizerVsx.Model 5 | { 6 | public class EncodingScrutatorFolder : EncodingScrutatorFolderFile 7 | { 8 | public EncodingScrutatorFolder(EncodingNormalior.Model.EncodingScrutatorFolder encodingScrutatorFolder, 9 | EncodingScrutatorFolder parent) 10 | : base(encodingScrutatorFolder.Name, parent) 11 | { 12 | Folder = new List(); 13 | foreach (var temp in encodingScrutatorFolder.File) 14 | Folder.Add(new EncodingScrutatorFile(temp, parent)); 15 | 16 | foreach (var temp in encodingScrutatorFolder.Folder) 17 | Folder.Add(new EncodingScrutatorFolder(temp, this)); 18 | SitpulationEncodingSetting = encodingScrutatorFolder.SitpulationEncodingSetting; 19 | } 20 | 21 | ///// 22 | ///// 把所有的文件写编码规范 23 | ///// 24 | //public void WriteSitpulationEncoding() 25 | //{ 26 | // foreach (var temp in Folder) 27 | // { 28 | // if (temp is EncodingScrutatorFile) 29 | // { 30 | 31 | // } 32 | // else if (temp is EncodingScrutatorFolder) 33 | // { 34 | // if (temp.Check) 35 | // { 36 | // ((EncodingScrutatorFolder)temp).WriteSitpulationEncoding(); 37 | // } 38 | // } 39 | // } 40 | //} 41 | 42 | public SitpulationEncodingSetting SitpulationEncodingSetting { get; } 43 | } 44 | } -------------------------------------------------------------------------------- /EncodingNormalior.WPF/Model/EncodingScrutatorFolderFile.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace EncodingNormalizerVsx.Model 4 | { 5 | public class EncodingScrutatorFolderFile : IEncodingScrutatorFile 6 | { 7 | public EncodingScrutatorFolderFile(string name) //, SitpulationEncodingSetting sitpulationEncodingSetting) 8 | { 9 | Name = name; 10 | //SitpulationEncodingSetting = sitpulationEncodingSetting; 11 | } 12 | 13 | public EncodingScrutatorFolderFile(string name, EncodingScrutatorFolder parent) 14 | { 15 | Name = name; 16 | Parent = parent; 17 | } 18 | 19 | public string Name { get; } 20 | public bool Check { get; set; } = true; 21 | public List Folder { get; set; } 22 | public EncodingScrutatorFolder Parent { get; set; } 23 | } 24 | } -------------------------------------------------------------------------------- /EncodingNormalior.WPF/Model/EncodingScrutatorProgress.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace EncodingNormalizerVsx.Model 4 | { 5 | public class EncodingScrutatorProgress : IProgress 6 | { 7 | public EventHandler ProgressChanged { set; get; } 8 | public EventHandler ExceptChanged { set; get; } 9 | public EventHandler WriteSitpulationFileChanged { set; get; } 10 | 11 | public void Report(EncodingNormalior.Model.EncodingScrutatorFile encodingScrutatorFile) 12 | { 13 | ProgressChanged?.Invoke(this, encodingScrutatorFile); 14 | } 15 | 16 | public void ReportExcept(Exception e) 17 | { 18 | ExceptChanged?.Invoke(this, e); 19 | } 20 | 21 | ///// 22 | ///// 需要处理总数 23 | ///// 24 | //public double Amount { set; get; } 25 | ///// 26 | ///// 当前数 27 | ///// 28 | //public double ProgressCount { set; get; } 29 | 30 | public void ReportWriteSitpulationFile(EncodingScrutatorFile encodingScrutatorFile) 31 | { 32 | WriteSitpulationFileChanged?.Invoke(this, encodingScrutatorFile); 33 | } 34 | } 35 | } -------------------------------------------------------------------------------- /EncodingNormalior.WPF/Model/IEncodingConverter.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | 3 | namespace EncodingNormalizerVsx.Model 4 | { 5 | public interface IEncodingConverter 6 | { 7 | string EncodingName { get; } 8 | string Read(FileInfo file); 9 | void Storage(string str, FileInfo file); 10 | } 11 | } -------------------------------------------------------------------------------- /EncodingNormalior.WPF/Model/IEncodingScrutatorFile.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace EncodingNormalizerVsx.Model 4 | { 5 | public interface IEncodingScrutatorFile 6 | { 7 | string Name { get; } 8 | bool Check { set; get; } 9 | List Folder { set; get; } 10 | 11 | EncodingScrutatorFolder Parent { set; get; } 12 | 13 | //SitpulationEncodingSetting SitpulationEncodingSetting { set; get; } 14 | } 15 | } -------------------------------------------------------------------------------- /EncodingNormalior.WPF/Model/Solution.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Diagnostics; 4 | using System.IO; 5 | using System.Linq; 6 | using System.Reflection; 7 | 8 | namespace EncodingNormalizerVsx.Model 9 | { 10 | public class Solution 11 | { 12 | //internal class SolutionParser 13 | //Name: Microsoft.Build.Construction.SolutionParser 14 | //Assembly: Microsoft.Build, Version=4.0.0.0 15 | 16 | static readonly Type s_SolutionParser; 17 | static readonly PropertyInfo s_SolutionParser_solutionReader; 18 | static readonly MethodInfo s_SolutionParser_parseSolution; 19 | static readonly PropertyInfo s_SolutionParser_projects; 20 | 21 | static Solution() 22 | { 23 | //s_SolutionParser_projects.GetValue() 24 | s_SolutionParser = Type.GetType("Microsoft.Build.Construction.SolutionParser, Microsoft.Build, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", false, false); 25 | if (s_SolutionParser != null) 26 | { 27 | s_SolutionParser_solutionReader = s_SolutionParser.GetProperty("SolutionReader", BindingFlags.NonPublic | BindingFlags.Instance); 28 | s_SolutionParser_projects = s_SolutionParser.GetProperty("Projects", BindingFlags.NonPublic | BindingFlags.Instance); 29 | s_SolutionParser_parseSolution = s_SolutionParser.GetMethod("ParseSolution", BindingFlags.NonPublic | BindingFlags.Instance); 30 | } 31 | } 32 | 33 | public List Projects { get; private set; } 34 | 35 | public Solution(string solutionFileName) 36 | { 37 | if (s_SolutionParser == null) 38 | { 39 | throw new InvalidOperationException("Can not find type 'Microsoft.Build.Construction.SolutionParser' are you missing a assembly reference to 'Microsoft.Build.dll'?"); 40 | } 41 | var solutionParser = s_SolutionParser.GetConstructors(BindingFlags.Instance | BindingFlags.NonPublic).First().Invoke(null); 42 | using (var streamReader = new StreamReader(solutionFileName)) 43 | { 44 | s_SolutionParser_solutionReader.SetValue(solutionParser, streamReader, null); 45 | s_SolutionParser_parseSolution.Invoke(solutionParser, null); 46 | } 47 | var projects = new List(); 48 | var array = (Array)s_SolutionParser_projects.GetValue(solutionParser, null); 49 | for (int i = 0; i < array.Length; i++) 50 | { 51 | projects.Add(new SolutionProject(array.GetValue(i))); 52 | } 53 | this.Projects = projects; 54 | GetProjectFullName(solutionFileName); 55 | //Object cfgArray = //s_SolutionParser_configurations.GetValue 56 | // s_SolutionParser_projects.GetValue(solutionParser, null); 57 | //PropertyInfo[] pInfos = null; 58 | //pInfos = cfgArray.GetType().GetProperties(); 59 | //int count = (int)pInfos[1].GetValue(cfgArray, null); 60 | 61 | //var configs = new List(); 62 | //for (int i = 0; i < count; i++) 63 | //{ 64 | // configs.Add(new SolutionConfiguration(pInfos[2].GetValue(cfgArray, new object[] { i }))); 65 | //} 66 | 67 | //this.Configurations = configs; 68 | } 69 | 70 | private void GetProjectFullName(string solutionFileName) 71 | { 72 | DirectoryInfo solution = (new FileInfo(solutionFileName)).Directory; 73 | foreach (var temp in Projects.Where 74 | //(temp=>temp.RelativePath.EndsWith("csproj")) 75 | (temp => !temp.RelativePath.Equals(temp.ProjectName)) 76 | ) 77 | { 78 | GetProjectFullName(solution, temp); 79 | } 80 | } 81 | 82 | private void GetProjectFullName(DirectoryInfo solution, SolutionProject project) 83 | { 84 | //Uri newUri =new Uri(,UriKind./*Absolute*/); 85 | //if(project.RelativePath) 86 | 87 | project.FullName = System.IO.Path.Combine(solution.FullName, project.RelativePath); 88 | } 89 | } 90 | 91 | [DebuggerDisplay("{ProjectName}, {RelativePath}, {ProjectGuid}")] 92 | public class SolutionProject 93 | { 94 | static readonly Type s_ProjectInSolution; 95 | static readonly PropertyInfo s_ProjectInSolution_ProjectName; 96 | static readonly PropertyInfo s_ProjectInSolution_RelativePath; 97 | static readonly PropertyInfo s_ProjectInSolution_ProjectGuid; 98 | static readonly PropertyInfo s_ProjectInSolution_ProjectType; 99 | 100 | static SolutionProject() 101 | { 102 | s_ProjectInSolution = Type.GetType("Microsoft.Build.Construction.ProjectInSolution, Microsoft.Build, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", false, false); 103 | if (s_ProjectInSolution != null) 104 | { 105 | s_ProjectInSolution_ProjectName = s_ProjectInSolution.GetProperty("ProjectName", BindingFlags.NonPublic | BindingFlags.Instance); 106 | s_ProjectInSolution_RelativePath = s_ProjectInSolution.GetProperty("RelativePath", BindingFlags.NonPublic | BindingFlags.Instance); 107 | s_ProjectInSolution_ProjectGuid = s_ProjectInSolution.GetProperty("ProjectGuid", BindingFlags.NonPublic | BindingFlags.Instance); 108 | s_ProjectInSolution_ProjectType = s_ProjectInSolution.GetProperty("ProjectType", BindingFlags.NonPublic | BindingFlags.Instance); 109 | } 110 | } 111 | 112 | public string ProjectName { get; private set; } 113 | public string RelativePath { get; private set; } 114 | public string ProjectGuid { get; private set; } 115 | public string ProjectType { get; private set; } 116 | public string FullName { set; get; } 117 | 118 | public SolutionProject(object solutionProject) 119 | { 120 | this.ProjectName = s_ProjectInSolution_ProjectName.GetValue(solutionProject, null) as string; 121 | this.RelativePath = s_ProjectInSolution_RelativePath.GetValue(solutionProject, null) as string; 122 | this.ProjectGuid = s_ProjectInSolution_ProjectGuid.GetValue(solutionProject, null) as string; 123 | this.ProjectType = s_ProjectInSolution_ProjectType.GetValue(solutionProject, null).ToString(); 124 | } 125 | } 126 | } -------------------------------------------------------------------------------- /EncodingNormalior.WPF/Model/Utf8WithoutBomEncodingConverter.cs: -------------------------------------------------------------------------------- 1 | using System.Text; 2 | 3 | namespace EncodingNormalizerVsx.Model 4 | { 5 | public class Utf8WithoutBomEncodingConverter : EncodingConverter, IEncodingConverter 6 | { 7 | /// 8 | public Utf8WithoutBomEncodingConverter() : base(new UTF8Encoding(false)) 9 | { 10 | } 11 | 12 | public override string EncodingName { get; } = "Utf8 without Bom"; 13 | } 14 | } -------------------------------------------------------------------------------- /EncodingNormalior.WPF/Model/WriteFolderEncoding.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Linq; 5 | using System.Text; 6 | 7 | namespace EncodingNormalizerVsx.Model 8 | { 9 | public static class WriteFolderEncoding 10 | { 11 | /// 12 | /// 把所有的文件写编码规范 13 | /// 14 | public static void WriteSitpulationEncoding(IEnumerable encodingScrutatorFolder, 15 | EncodingScrutatorProgress progress, Encoding encoding) 16 | { 17 | foreach (var temp in encodingScrutatorFolder.Where(temp => temp.Check)) 18 | { 19 | if (temp is EncodingScrutatorFile) 20 | { 21 | var file = (EncodingScrutatorFile) temp; 22 | progress.ReportWriteSitpulationFile(file); 23 | try 24 | { 25 | //file.WriteSitpulationEncoding(encoding); 26 | // 重写文件编码 27 | 28 | WriteSitpulationFileEncoding(file, encoding); 29 | file.Check = false; 30 | } 31 | catch (Exception e) 32 | { 33 | progress.ReportExcept(e); 34 | } 35 | } 36 | else if (temp is EncodingScrutatorFolder) 37 | { 38 | WriteSitpulationEncoding(((EncodingScrutatorFolder) temp).Folder, progress, encoding); 39 | } 40 | } 41 | } 42 | 43 | private static void WriteSitpulationFileEncoding(EncodingScrutatorFile file,Encoding encoding) 44 | { 45 | if (file.Encoding.Equals(Encoding.ASCII)) 46 | { 47 | if (Equals(encoding, Encoding.UTF8) || 48 | Equals(encoding, Encoding.GetEncoding("GBK")) || 49 | Equals(encoding, Encoding.ASCII)) //对 ASCII不写入 50 | { 51 | return; 52 | } 53 | } 54 | string str; 55 | using (var stream = new StreamReader(file.File.OpenRead(), file.Encoding)) 56 | { 57 | str = stream.ReadToEnd(); 58 | } 59 | using (var stream = new StreamWriter(new FileStream(file.File.FullName, FileMode.Create), encoding)) 60 | { 61 | stream.Write(str); 62 | } 63 | 64 | } 65 | } 66 | } -------------------------------------------------------------------------------- /EncodingNormalior.WPF/Resources/ConvertFileEncoding.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet-campus/EncodingNormalior/1c7cee71b1626e340a40f783882148aa2ac29958/EncodingNormalior.WPF/Resources/ConvertFileEncoding.png -------------------------------------------------------------------------------- /EncodingNormalior.WPF/Resources/EncodingNormalizer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet-campus/EncodingNormalior/1c7cee71b1626e340a40f783882148aa2ac29958/EncodingNormalior.WPF/Resources/EncodingNormalizer.png -------------------------------------------------------------------------------- /EncodingNormalior.WPF/Resources/EncodingNormalizerPackage.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet-campus/EncodingNormalior/1c7cee71b1626e340a40f783882148aa2ac29958/EncodingNormalior.WPF/Resources/EncodingNormalizerPackage.ico -------------------------------------------------------------------------------- /EncodingNormalior.WPF/Resources/Icon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet-campus/EncodingNormalior/1c7cee71b1626e340a40f783882148aa2ac29958/EncodingNormalior.WPF/Resources/Icon.ico -------------------------------------------------------------------------------- /EncodingNormalior.WPF/Resources/Logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet-campus/EncodingNormalior/1c7cee71b1626e340a40f783882148aa2ac29958/EncodingNormalior.WPF/Resources/Logo.png -------------------------------------------------------------------------------- /EncodingNormalior.WPF/Resources/QQ截图20170114120751.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet-campus/EncodingNormalior/1c7cee71b1626e340a40f783882148aa2ac29958/EncodingNormalior.WPF/Resources/QQ截图20170114120751.png -------------------------------------------------------------------------------- /EncodingNormalior.WPF/Resources/QQ截图2017011412075116.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet-campus/EncodingNormalior/1c7cee71b1626e340a40f783882148aa2ac29958/EncodingNormalior.WPF/Resources/QQ截图2017011412075116.png -------------------------------------------------------------------------------- /EncodingNormalior.WPF/Resources/code_711px_1157693_easyicon.net.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet-campus/EncodingNormalior/1c7cee71b1626e340a40f783882148aa2ac29958/EncodingNormalior.WPF/Resources/code_711px_1157693_easyicon.net.png -------------------------------------------------------------------------------- /EncodingNormalior.WPF/Resources/code_711px_16_easyicon.net.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet-campus/EncodingNormalior/1c7cee71b1626e340a40f783882148aa2ac29958/EncodingNormalior.WPF/Resources/code_711px_16_easyicon.net.png -------------------------------------------------------------------------------- /EncodingNormalior.WPF/View/Button.xaml: -------------------------------------------------------------------------------- 1 |  3 | 4 | 6 | 8 | 12 | 16 | 17 | 18 | 19 | 20 | 21 | 23 | 25 | 26 | 27 | 28 | 29 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 51 | 53 | 54 | 55 | 56 | 57 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 79 | 81 | 82 | 83 | 84 | 85 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 98 | 99 | 100 | 101 | 102 | 103 | 105 | 106 | 107 | 108 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 146 | 19 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 52 | 53 | 54 | 55 | 58 | 59 | 60 | 61 | 63 | 83 | 84 | 93 | 94 | 103 | 104 | 113 | 114 | 115 | 116 | 117 | 118 | 123 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | -------------------------------------------------------------------------------- /EncodingNormalizerVsix/GuidStrings.cs: -------------------------------------------------------------------------------- 1 | namespace EncodingNormalizerVsx 2 | { 3 | /// 4 | /// This class contains a list of GUIDs specific to this sample. 5 | /// 6 | public static class GuidStrings 7 | { 8 | /// 9 | /// Guid for the OptionsPagePackage class. 10 | /// 11 | public const string GuidPackage = "B0002DC2-56EE-4931-93F7-70D6E9863940"; 12 | 13 | /// 14 | /// Guid for the OptionsPageGeneral class. 15 | /// 16 | public const string GuidDefinitionPage = "E6717D0B-111E-4a5b-9834-076CA319ED59"; 17 | 18 | /// 19 | /// Guid for the OptionsPageCustom class. 20 | /// 21 | public const string GuidPageCustom = "0A9F3920-3881-4f50-8986-9EDEC7B33566"; 22 | } 23 | } -------------------------------------------------------------------------------- /EncodingNormalizerVsix/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("EncodingNormalizerVsix")] 9 | [assembly: AssemblyDescription("Encoding tool can check all files in solution and normalize the encoding")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("dotnet campus")] 12 | [assembly: AssemblyProduct("EncodingNormalizerVsix")] 13 | [assembly: AssemblyCopyright("Copyright (c) 2020-2021 dotnet-campus")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // Version information for an assembly consists of the following four values: 23 | // 24 | // Major Version 25 | // Minor Version 26 | // Build Number 27 | // Revision 28 | // 29 | // You can specify all the values or you can default the Build and Revision Numbers 30 | // by using the '*' as shown below: 31 | // [assembly: AssemblyVersion("1.0.*")] 32 | [assembly: AssemblyVersion("3.0.0.0")] 33 | [assembly: AssemblyFileVersion("3.0.0.0")] 34 | -------------------------------------------------------------------------------- /EncodingNormalizerVsix/Resources/ConvertFileEncoding.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet-campus/EncodingNormalior/1c7cee71b1626e340a40f783882148aa2ac29958/EncodingNormalizerVsix/Resources/ConvertFileEncoding.png -------------------------------------------------------------------------------- /EncodingNormalizerVsix/Resources/EncodingNormalizer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet-campus/EncodingNormalior/1c7cee71b1626e340a40f783882148aa2ac29958/EncodingNormalizerVsix/Resources/EncodingNormalizer.png -------------------------------------------------------------------------------- /EncodingNormalizerVsix/Resources/EncodingNormalizerPackage.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet-campus/EncodingNormalior/1c7cee71b1626e340a40f783882148aa2ac29958/EncodingNormalizerVsix/Resources/EncodingNormalizerPackage.ico -------------------------------------------------------------------------------- /EncodingNormalizerVsix/Resources/Icon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet-campus/EncodingNormalior/1c7cee71b1626e340a40f783882148aa2ac29958/EncodingNormalizerVsix/Resources/Icon.ico -------------------------------------------------------------------------------- /EncodingNormalizerVsix/Resources/Logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet-campus/EncodingNormalior/1c7cee71b1626e340a40f783882148aa2ac29958/EncodingNormalizerVsix/Resources/Logo.png -------------------------------------------------------------------------------- /EncodingNormalizerVsix/Resources/QQ截图20170114120751.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet-campus/EncodingNormalior/1c7cee71b1626e340a40f783882148aa2ac29958/EncodingNormalizerVsix/Resources/QQ截图20170114120751.png -------------------------------------------------------------------------------- /EncodingNormalizerVsix/Resources/QQ截图2017011412075116.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet-campus/EncodingNormalior/1c7cee71b1626e340a40f783882148aa2ac29958/EncodingNormalizerVsix/Resources/QQ截图2017011412075116.png -------------------------------------------------------------------------------- /EncodingNormalizerVsix/Resources/code_711px_1157693_easyicon.net.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet-campus/EncodingNormalior/1c7cee71b1626e340a40f783882148aa2ac29958/EncodingNormalizerVsix/Resources/code_711px_1157693_easyicon.net.png -------------------------------------------------------------------------------- /EncodingNormalizerVsix/Resources/code_711px_16_easyicon.net.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet-campus/EncodingNormalior/1c7cee71b1626e340a40f783882148aa2ac29958/EncodingNormalizerVsix/Resources/code_711px_16_easyicon.net.png -------------------------------------------------------------------------------- /EncodingNormalizerVsix/source.extension.vsixmanifest: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Encoding normalize tool 6 | Encoding tool can check all files in solution and normalize the encoding. 规范化文件编码工具 7 | https://github.com/dotnet-campus/EncodingNormalior 8 | Resources\code_711px_1157693_easyicon.net.png 9 | Resources\code_711px_1157693_easyicon.net.png 10 | 11 | 12 | 13 | amd64 14 | 15 | 16 | amd64 17 | 18 | 19 | amd64 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /EncodingNormalizerVsx/DefinitionPage.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.ComponentModel; 3 | using System.Runtime.InteropServices; 4 | using System.Text; 5 | using Microsoft.VisualStudio.Shell; 6 | 7 | namespace EncodingNormalizerVsx 8 | { 9 | //public class FileInclude 10 | //{ 11 | // public FileInclude() 12 | // { 13 | 14 | // } 15 | 16 | // public string Name { set; get; } 17 | //} 18 | 19 | //public enum CriterionEncoding 20 | //{ 21 | // Utf8, 22 | // Unicode16, 23 | // Gbk, 24 | //} 25 | 26 | //[ClassInterface(ClassInterfaceType.AutoDispatch)] 27 | //[Guid(GuidStrings.GuidDefinitionPage)] 28 | //public class DefinitionPage : DialogPage 29 | //{ 30 | // public DefinitionPage() 31 | // { 32 | // //OptionString = "Hello World"; 33 | // //OptionInteger = 567; 34 | // //CustomSize = new Size(50, 50); 35 | 36 | // CriterionEncoding = CriterionEncoding.Utf8; 37 | // //FileInclude=new List(); 38 | // //FileInclude=new FileInclude[1]; 39 | // } 40 | // /// 41 | // /// 规范格式 42 | // /// 43 | // [Category("规定编码")] 44 | // [Description("规定的编码,如果是ascii 那么无论是选择utf8或GBK都判断为对")] 45 | // public CriterionEncoding CriterionEncoding { set; get; } 46 | 47 | // /// 48 | // /// 不能做 49 | // /// 50 | // [Category("包括文件")] 51 | // [Description("包括文件的后缀名")] 52 | // public FileInclude[] FileInclude { set; get; } 53 | 54 | 55 | 56 | // /// 57 | // /// Gets or sets the String type custom option value. 58 | // /// 59 | // /// This value is shown in the options page. 60 | // [Category("String Options")] 61 | // [Description("My string option")] 62 | // public string OptionString { get; set; } 63 | 64 | // ///// 65 | // ///// Gets or sets the integer type custom option value. 66 | // ///// 67 | // ///// This value is shown in the options page. 68 | // //[Category("Integer Options")] 69 | // //[Description("My integer option")] 70 | // //public int OptionInteger { get; set; } 71 | 72 | // ///// 73 | // ///// Gets or sets the Size type custom option value. 74 | // ///// 75 | // ///// This value is shown in the options page. 76 | // //[Category("Expandable Options")] 77 | // //[Description("My Expandable option")] 78 | // //public Size CustomSize { get; set; } 79 | 80 | 81 | // //protected override IWin32Window Window 82 | // //{ 83 | // // get 84 | // // { 85 | // // if (_definitionPage == null) 86 | // // { 87 | // // _definitionPage = new View.DefinitionPage(); 88 | // // } 89 | // // _definitionPage.Owner = this; 90 | // // _definitionPage.InitializeLifetimeService(); 91 | // // return _definitionPage; 92 | // // } 93 | // //} 94 | // //private View.DefinitionPage _definitionPage; 95 | //} 96 | } -------------------------------------------------------------------------------- /EncodingNormalizerVsx/EncodingNormalizerPackage.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // Copyright (c) Company. All rights reserved. 4 | // 5 | //------------------------------------------------------------------------------ 6 | 7 | using System; 8 | using System.Diagnostics.CodeAnalysis; 9 | using System.Runtime.InteropServices; 10 | using Microsoft.VisualStudio; 11 | using Microsoft.VisualStudio.Shell; 12 | using Microsoft.VisualStudio.Shell.Interop; 13 | 14 | namespace EncodingNormalizerVsx 15 | { 16 | /// 17 | /// This is the class that implements the package exposed by this assembly. 18 | /// 19 | /// 20 | /// 21 | /// The minimum requirement for a class to be considered a valid package for Visual Studio 22 | /// is to implement the IVsPackage interface and register itself with the shell. 23 | /// This package uses the helper classes defined inside the Managed Package Framework (MPF) 24 | /// to do it: it derives from the Package class that provides the implementation of the 25 | /// IVsPackage interface and uses the registration attributes defined in the framework to 26 | /// register itself and its components with the shell. These attributes tell the pkgdef creation 27 | /// utility what data to put into .pkgdef file. 28 | /// 29 | /// 30 | /// To get loaded into VS, the package must be referred by <Asset Type="Microsoft.VisualStudio.VsPackage" ... 31 | /// > in .vsixmanifest file. 32 | /// 33 | /// 34 | [PackageRegistration(UseManagedResourcesOnly = true)] 35 | [InstalledProductRegistration("#110", "#112", "1.0", IconResourceID = 400)] // Info on this package for Help/About 36 | [ProvideMenuResource("Menus.ctmenu", 1)] 37 | [Guid(PackageGuidString)] 38 | [SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1650:ElementDocumentationMustBeSpelledCorrectly", 39 | Justification = "pkgdef, VS and vsixmanifest are valid VS terms")] 40 | //[ProvideProfile(typeof(DefinitionPage), "EncodingNormalizer", "DefinitionPage", 101, 104, true)] 41 | //[ProvideOptionPage(typeof(DefinitionPage), "EncodingNormalizer", "DefinitionPage", 101, 104, true)] 42 | public sealed class EncodingNormalizerPackage : Package 43 | { 44 | /// 45 | /// EncodingNormalizerPackage GUID string. 46 | /// 47 | public const string PackageGuidString = "ffc5dabf-5ded-4433-8225-73b47e154210"; 48 | 49 | #region Package Members 50 | 51 | /// 52 | /// Initialization of the package; this method is called right after the package is sited, so this is the place 53 | /// where you can put all the initialization code that rely on services provided by VisualStudio. 54 | /// 55 | protected override void Initialize() 56 | { 57 | EncodingNormalizer.Initialize(this); 58 | base.Initialize(); 59 | } 60 | 61 | public static EncodingNormalizerPackage EnsureEncodingNormalizerPackage() 62 | { 63 | var shell = GetGlobalService(typeof(SVsShell)) as IVsShell; 64 | if (shell != null) 65 | { 66 | IVsPackage package; 67 | var guid = new Guid(PackageGuidString); 68 | if (ErrorHandler.Succeeded(shell.IsPackageLoaded(ref guid, out package))) 69 | return package as EncodingNormalizerPackage; 70 | if (ErrorHandler.Succeeded(shell.LoadPackage(ref guid, out package))) 71 | return package as EncodingNormalizerPackage; 72 | } 73 | return null; 74 | } 75 | 76 | //public static DefinitionPage DefinitionPage() 77 | //{ 78 | // EncodingNormalizerPackage package = EnsureEncodingNormalizerPackage(); 79 | // return package?.GetDialogPage(typeof(DefinitionPage)) as DefinitionPage; 80 | //} 81 | 82 | #endregion 83 | } 84 | } -------------------------------------------------------------------------------- /EncodingNormalizerVsx/EncodingNormalizerPackage.vsct: -------------------------------------------------------------------------------- 1 |  2 | 3 | 5 | 6 | 11 | 12 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 27 | 28 | 35 | 36 | 40 | 41 | 42 | 44 | 45 | 46 | 47 | 48 | 49 | 规范编码 50 | 51 | EncodingNormalizer 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 66 | 67 | 74 | 83 | 84 | 93 | 94 | 103 | 104 | 113 | 114 | 115 | 116 | 117 | 118 | 123 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | -------------------------------------------------------------------------------- /EncodingNormalizerVsx/GuidStrings.cs: -------------------------------------------------------------------------------- 1 | namespace EncodingNormalizerVsx 2 | { 3 | /// 4 | /// This class contains a list of GUIDs specific to this sample. 5 | /// 6 | public static class GuidStrings 7 | { 8 | /// 9 | /// Guid for the OptionsPagePackage class. 10 | /// 11 | public const string GuidPackage = "B0002DC2-56EE-4931-93F7-70D6E9863940"; 12 | 13 | /// 14 | /// Guid for the OptionsPageGeneral class. 15 | /// 16 | public const string GuidDefinitionPage = "E6717D0B-111E-4a5b-9834-076CA319ED59"; 17 | 18 | /// 19 | /// Guid for the OptionsPageCustom class. 20 | /// 21 | public const string GuidPageCustom = "0A9F3920-3881-4f50-8986-9EDEC7B33566"; 22 | } 23 | } -------------------------------------------------------------------------------- /EncodingNormalizerVsx/Key.snk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet-campus/EncodingNormalior/1c7cee71b1626e340a40f783882148aa2ac29958/EncodingNormalizerVsx/Key.snk -------------------------------------------------------------------------------- /EncodingNormalizerVsx/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.InteropServices; 3 | 4 | // General Information about an assembly is controlled through the following 5 | // set of attributes. Change these attribute values to modify the information 6 | // associated with an assembly. 7 | 8 | [assembly: AssemblyTitle("EncodingNormalizerVsx")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("EncodingNormalizerVsx")] 13 | [assembly: AssemblyCopyright("")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | 21 | [assembly: ComVisible(false)] 22 | 23 | // Version information for an assembly consists of the following four values: 24 | // 25 | // Major Version 26 | // Minor Version 27 | // Build Number 28 | // Revision 29 | // 30 | // You can specify all the values or you can default the Build and Revision Numbers 31 | // by using the '*' as shown below: 32 | // [assembly: AssemblyVersion("1.0.*")] 33 | 34 | [assembly: AssemblyVersion("1.0.20.0")] 35 | [assembly: AssemblyFileVersion("1.0.26.0")] 36 | [assembly: Guid("0640f5ce-e6bc-43ba-b45e-497d70819a20")] 37 | 38 | -------------------------------------------------------------------------------- /EncodingNormalizerVsx/Resources/ConvertFileEncoding.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet-campus/EncodingNormalior/1c7cee71b1626e340a40f783882148aa2ac29958/EncodingNormalizerVsx/Resources/ConvertFileEncoding.png -------------------------------------------------------------------------------- /EncodingNormalizerVsx/Resources/EncodingNormalizer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet-campus/EncodingNormalior/1c7cee71b1626e340a40f783882148aa2ac29958/EncodingNormalizerVsx/Resources/EncodingNormalizer.png -------------------------------------------------------------------------------- /EncodingNormalizerVsx/Resources/EncodingNormalizerPackage.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet-campus/EncodingNormalior/1c7cee71b1626e340a40f783882148aa2ac29958/EncodingNormalizerVsx/Resources/EncodingNormalizerPackage.ico -------------------------------------------------------------------------------- /EncodingNormalizerVsx/Resources/Icon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet-campus/EncodingNormalior/1c7cee71b1626e340a40f783882148aa2ac29958/EncodingNormalizerVsx/Resources/Icon.ico -------------------------------------------------------------------------------- /EncodingNormalizerVsx/Resources/Logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet-campus/EncodingNormalior/1c7cee71b1626e340a40f783882148aa2ac29958/EncodingNormalizerVsx/Resources/Logo.png -------------------------------------------------------------------------------- /EncodingNormalizerVsx/Resources/QQ截图20170114120751.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet-campus/EncodingNormalior/1c7cee71b1626e340a40f783882148aa2ac29958/EncodingNormalizerVsx/Resources/QQ截图20170114120751.png -------------------------------------------------------------------------------- /EncodingNormalizerVsx/Resources/QQ截图2017011412075116.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet-campus/EncodingNormalior/1c7cee71b1626e340a40f783882148aa2ac29958/EncodingNormalizerVsx/Resources/QQ截图2017011412075116.png -------------------------------------------------------------------------------- /EncodingNormalizerVsx/Resources/code_711px_1157693_easyicon.net.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet-campus/EncodingNormalior/1c7cee71b1626e340a40f783882148aa2ac29958/EncodingNormalizerVsx/Resources/code_711px_1157693_easyicon.net.png -------------------------------------------------------------------------------- /EncodingNormalizerVsx/Resources/code_711px_16_easyicon.net.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet-campus/EncodingNormalior/1c7cee71b1626e340a40f783882148aa2ac29958/EncodingNormalizerVsx/Resources/code_711px_16_easyicon.net.png -------------------------------------------------------------------------------- /EncodingNormalizerVsx/VSPackage.resx: -------------------------------------------------------------------------------- 1 |  2 | 12 | 13 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | text/microsoft-resx 120 | 121 | 122 | 2.0 123 | 124 | 125 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 126 | 127 | 128 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 129 | 130 | 131 | 132 | EncodingNormalizer Extension 133 | 134 | 135 | EncodingNormalizer Visual Studio Extension Detailed Info 136 | 137 | 138 | Resources\EncodingNormalizerPackage.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a 139 | 140 | -------------------------------------------------------------------------------- /EncodingNormalizerVsx/app.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /EncodingNormalizerVsx/index.html: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | Getting Started 9 | 10 | 11 | 12 |
13 | 17 | 18 |
19 |
20 |

Creating a Visual Studio Extension

21 | 22 |

This project enables developers to create an extension for Visual Studio. The solution contains a VSIX project that packages the extension into a VSIX file. This file is used to install an extension for Visual Studio.

23 |

Add new features

24 | 25 |
    26 |
  1. Right-click the project node in Solution Explorer and select Add>New Item.
  2. 27 |
  3. In the Add New Item dialog box, expand the Extensibility node under Visual C# or Visual Basic.
  4. 28 |
  5. Choose from the available item templates: Visual Studio Package, Editor Items (Classifier, Margin, Text Adornment, Viewport Adornment), Command, Tool Window, Toolbox Control, and then click Add.
  6. 29 |
30 | 31 |

The files for the template that you selected are added to the project. You can start adding functionality to your item template, press F5 to run the project, or add additional item templates.

32 | 33 |

Run and debug

34 |

To run the project, press F5. Visual Studio will:

35 | 36 |
    37 |
  • Build the extension from the VSIX project.
  • 38 |
  • Create a VSIX package from the VSIX project.
  • 39 |
  • When debugging, start an experimental instance of Visual Studio with the VSIX package installed.
  • 40 |
41 | 42 |

In the experimental instance of Visual Studio you can test out the functionality of your extension without affecting your Visual Studio installation.

43 | 44 |
45 |
46 |
47 |

Visual Studio Extensibility Resources

48 | 49 |
    50 |
  1. MSDN documentation
    Detailed documentation and API reference material for building extensions.
  2. 51 |
  3. Extension samples on GitHub
    Use a sample project to kickstart your development.
  4. 52 |
  5. Extensibility chat room on Gitter
    Meet other extension developers and exchange tips and tricks for extension development.
  6. 53 |
  7. Channel 9 videos on extensibility
    Watch videos from the product team on Visual Studio extensibility.
  8. 54 |
  9. Extensibility Tools 2015
    Install an optional helper tool that adds extra IDE support for extension authors.
  10. 55 |
56 |

Give us feedback

57 | 62 |
63 |
64 |
65 |
66 | 67 | -------------------------------------------------------------------------------- /EncodingNormalizerVsx/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /EncodingNormalizerVsx/source.extension.vsixmanifest: -------------------------------------------------------------------------------- 1 |  2 | 3 | 5 | 6 | 8 | Encoding normalize tool 9 | Encoding tool can check all files in solution and normalize the encoding 10 | https://github.com/dotnet-campus/EncodingNormalior 11 | Resources\code_711px_1157693_easyicon.net.png 12 | Resources\code_711px_1157693_easyicon.net.png 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 24 | 25 | 26 | 28 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /EncodingNormalizerVsx/stylesheet.css: -------------------------------------------------------------------------------- 1 | body { 2 | border: 0; 3 | color: #1E1E1E; 4 | font-family: "Segoe UI", Helvetica, Arial, sans-serif; 5 | font-size: 13px; 6 | line-height: 1.45; 7 | margin: 0; 8 | padding: 0; 9 | word-wrap: break-word; 10 | } 11 | 12 | /* General & 'Reset' Stuff */ 13 | 14 | 15 | .container { 16 | margin: 0 auto; 17 | width: 980px; 18 | } 19 | 20 | section { 21 | display: block; 22 | margin: 0; 23 | } 24 | 25 | h1, h2, h3, h4, h5, h6 { margin: 0; } 26 | 27 | /* Header,
28 | header - container 29 | h1 - project name 30 | h2 - project description 31 | */ 32 | 33 | #header { 34 | background: #68217a; 35 | color: #FFF; 36 | position: relative; 37 | } 38 | 39 | #hangcloud { 40 | background: url("../images/bannerart03.png"); 41 | height: 160px; 42 | position: absolute; 43 | right: -30px; 44 | top: 0; 45 | width: 190px; 46 | } 47 | 48 | h1, h2 { 49 | font-family: "Segoe UI Light", "Segoe UI", Helvetica, Arial, sans-serif; 50 | line-height: 1; 51 | margin: 0 18px; 52 | padding: 0; 53 | } 54 | 55 | #header h1 { 56 | font-size: 3.4em; 57 | font-weight: normal; 58 | margin-left: 15px; 59 | padding-top: 18px; 60 | } 61 | 62 | #header h2 { 63 | font-size: 1.5em; 64 | font-weight: normal; 65 | margin-top: 10px; 66 | padding-bottom: 18px; 67 | } 68 | 69 | 70 | #main_content { 71 | display: flex; 72 | flex-direction: row; 73 | width: 100%; 74 | } 75 | 76 | 77 | h1, h2, h3, h4, h5, h6 { font-weight: bolder; } 78 | 79 | #main_content h1 { 80 | font-size: 1.8em; 81 | margin-top: 34px; 82 | } 83 | 84 | #main_content h1:first-child { margin-top: 30px; } 85 | 86 | #main_content h2 { 87 | font-size: 1.4em; 88 | font-weight: bold; 89 | } 90 | 91 | p, ul { margin: 11px 18px; } 92 | 93 | #main_content a { 94 | color: #06C; 95 | text-decoration: none; 96 | } 97 | 98 | ul { 99 | margin-left: 18px; 100 | margin-top: 13px; 101 | padding-left: 0; 102 | } 103 | 104 | ul li { 105 | margin-left: 18px; 106 | padding-left: 0; 107 | } 108 | 109 | #lpanel { 110 | float: left; 111 | width: 620px; 112 | } 113 | 114 | #rpanel ul { 115 | list-style-type: none; 116 | width: 300px; 117 | } 118 | 119 | #rpanel ul li { line-height: 1.8em; } 120 | 121 | #rpanel { 122 | background: #e7e7e7; 123 | float: right; 124 | width: 360px; 125 | } 126 | 127 | #rpanel div { width: 300px; } -------------------------------------------------------------------------------- /EncodingUtf8AndGBKDifferentiater/EncodingUtf8AndGBKDifferentiater.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Library 5 | net45;netcoreapp2.1; 6 | 7 | 8 | true 9 | lindexi.src.EncodingUtf8AndGBKDifferentiater 10 | 判断文件的编码是什么,可以区分 Utf8 和 GBK 可以判断文件的编码可信度 11 | 12 | 使用方法是调用 EncodingDifferentiater 的 DifferentiateEncoding 方法,可以判断文件是什么编码 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | all 22 | runtime; build; native; contentfiles; analyzers 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 dotnet campus 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # 编码检测和修改工具 2 | 3 | | Appveyor Build | GitHub Action | 4 | | -- | -- | 5 | |[![Build status](https://ci.appveyor.com/api/projects/status/ypcqbbc7bsexnfog?svg=true)](https://ci.appveyor.com/project/lindexi_gd/encodingnormalior)| ![](https://github.com/dotnet-campus/EncodingNormalior/workflows/.NET%20Core/badge.svg) | 6 | 7 | | Package Name | Release (NuGet) | 8 | |--------------------------------|-----------------| 9 | | `dotnetCampus.EncodingNormalior` |[![NuGet](https://img.shields.io/nuget/v/dotnetCampus.EncodingNormalior.svg)](https://www.nuget.org/packages/dotnetCampus.EncodingNormalior/)| 10 | | `lindexi.src.EncodingUtf8AndGBKDifferentiater` |[![NuGet](https://img.shields.io/nuget/v/lindexi.src.EncodingUtf8AndGBKDifferentiater.svg)](https://www.nuget.org/packages/lindexi.src.EncodingUtf8AndGBKDifferentiater/)| 11 | 12 | 在开发中经常遇到编码不一致的文件,而如果这些文件包含需要显示的字符串,就会导致在乱码。所以需要一个工具可以自动检测工程、文件夹内所有文本的编码,并可以规范所有文件编码。 13 | 14 | 工具要求可以设置规定的编码,如果文件的编码不是规定的编码,用户可以选择把文件的编码转换为规定的编码。 15 | 16 | 用户可以设置白名单,白名单可以让某些文件或文件夹的文件不检测。 17 | 18 | 默认是检测所有的文本文件,但是因为没有一个好的算法,所以在无法判断一个文件是文本时,会去查看用户是不是设置了一定包含某个文件后缀,一旦文件在用户的包含后缀中,那么就会去检测文件编码。 19 | 20 | 程序首先是检查文件是否在白名单,如果不在,再检测是否包含文件后缀,如果没有,再检测文件是否是文本,如果是的话,就检查。 21 | 22 | 23 | 24 | 25 | 26 | 首先是告诉大家如何使用工具。 27 | 28 | ## 工具的使用 29 | 30 | ### 命令行使用 31 | 32 | 命令行使用参见:[编码工具——命令行](./EncodingNormalior/README.md) 33 | 34 | ### 插件使用 35 | 36 | 首先是下载插件,插件可以到 [https://visualstudiogallery.msdn.microsoft.com/a5f50c64-1b75-4f7a-97fd-9545747c506a](https://marketplace.visualstudio.com/items?itemName=lindexigd.vs-extension-18109) 下载,也可以在 [VS 插件网](https://marketplace.visualstudio.com/vs) 搜索 `Encoding` 就可以找到我的工具啦。可以说我翻遍了整个插件网,都没有找到我这个功能的插件(这句话是在2017年说的),但是还是找到了一些有用的插件。 37 | 38 | ![](http://cdn.lindexi.site/8f464be7-2358-45f4-b6cd-eae32c47a878201727162028.jpg) 39 | 40 | 打开 Visual Sutido ,在安装完 [编码规范工具](https://marketplace.visualstudio.com/items?itemName=lindexigd.vs-extension-18109) ,可以看到菜单多了 选项 EncodingNormalizer 41 | 42 | ![](http://cdn.lindexi.site/lindexi%2F2019461567484) 43 | 44 | 然后来说下我做的功能。 45 | 46 | #### 修改当前文件编码 47 | 48 | 在 2.6 版本新添加的功能是修改当前打开的文件的编码,即使这个文件不在当前的项目里面 49 | 50 | 因为现在没有一个方法可以知道一个文件是什么编码,所以可以在插件自己手动选当前文件的编码,这样可以解决识别编码错误 51 | 52 | ![](http://cdn.lindexi.site/lindexi%2F202022911598327.jpg) 53 | 54 | 选择当前的文件的编码,和需要转换的文件的编码,然后点击 Convert 就可以转换了 55 | 56 | 57 | 58 | ![](http://cdn.lindexi.site/lindexi%2F201946153140370) 59 | 60 | 现在能支持的转换的编码是带符号的 Utf-8 和 GBK 编码 61 | 62 | #### 设置 63 | 64 | 点击菜单 EncodingNormailzer ,选择 Setting 可以看到下面界面 65 | 66 | 67 | 68 | ![](http://cdn.lindexi.site/lindexi%2F201946151729613) 69 | 70 | 首先是可以忽略一些文件或文件夹,默认是忽略一些不是文本的文件和 bin、obj、git文件夹,注意,千万不要去转换 git 文件夹的代码。 71 | 72 | 然后我们可以设置编码,现在做的是 Utf8 、GBK、Unicode的编码,如果检测工程存在文件的编码和我们设置的不一样,就会提示去转换。 73 | 74 | 因为 Ascii 的文件,存放为 GBK 和 UTF8不带签名是无法区分的,所以忽略 ASCII 编码文件。 75 | 76 | 因为对 Unicode-16 的文件是无法使用判断存在 '\0' 来区分文件是不是文本,所以,对于某些文件还是自己手动添加是否一定检测,对于没有被添加到一定需要检测的文件,先判断他是不是文本,如果是的话,就检测。 77 | 78 | 设置保存在 `我的文档\EncodingNormalizer\Account.json` 文件 79 | 80 | #### 检查编码 81 | 82 | 然后在打开完工程,注意要加载完成才使用。 83 | 84 | 点击 Conform solution encoding ,自动检测方案所有工程的文件编码,如果发现所有的编码都符合规范,那么弹出窗口说所有文件都符合规范。如果有文件不符合规范,那么提示用户是否转换。 85 | 86 | 87 | 88 | 89 | ![](http://cdn.lindexi.site/lindexi%2F201946151823827) 90 | 91 | 找到所有不符合规范的文件,可以一键点击转换 92 | 93 | ![](http://cdn.lindexi.site/lindexi%2F20194615184676) 94 | 95 | 96 | 97 | ## 和我组队做工具 98 | 99 | 这个工具相信是大家比较需要的,所以我就做了这个工具。做这个工具最难的地方在于判断文件编码,和如何做vs扩展两个。如果大家也想做一个差不多的东西,可以参见开发过程中使用的技术:[C# 判断文件编码](https://blog.lindexi.com/post/C-%E5%88%A4%E6%96%AD%E6%96%87%E4%BB%B6%E7%BC%96%E7%A0%81.html ) [VisualStudio 扩展开发](https://blog.lindexi.com/post/VisualStudio-%E6%89%A9%E5%B1%95%E5%BC%80%E5%8F%91.html ) 100 | 101 | 我把工具放在 github : [https://github.com/dotnet-campus/EncodingNormalior](https://github.com/dotnet-campus/EncodingNormalior) 102 | 103 | 好像我的项目名称 编码规范工具 是 EncodingNormalizer ,写错了,但是不想改。 104 | 105 | 我还把他放在 vs 扩展库,可以到 [https://marketplace.visualstudio.com/](https://marketplace.visualstudio.com/) 下载。 106 | 107 | 来说下如何使用我的项目: 108 | 109 | 我的项目有类库 EncodingNormalior 和插件 EncodingNormalizerVsx。 110 | 111 | 如果想运行类库,不需要做任何修改。如果想运行插件,需要修改属性->调试,使用外部程序,里面写`C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\devenv.exe` 我现在是 VisualStudio 2015 所以是在`Visual Studio 14.0` 112 | 113 | 然后修改命令行参数:`/rootsuffix Exp` 114 | 115 | 然后就可以运行。 116 | 117 | 118 | 119 | 如果希望开发这个项目,可以去fork我的github库。 120 | 121 | 如果现在使用的是 visualStudio 2017 企业版,那么把外部程序修改为`C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\devenv.exe` 122 | 123 | 现在使用 VisualStudio 2019 社区版,将外部程序修改为 `C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\devenv.exe` 124 | 125 | 136 | -------------------------------------------------------------------------------- /appveyor.yml: -------------------------------------------------------------------------------- 1 | image: Visual Studio 2019 2 | 3 | install: 4 | - ps: (new-object Net.WebClient).DownloadString("https://raw.github.com/madskristensen/ExtensionScripts/master/AppVeyor/vsix.ps1") | iex 5 | 6 | before_build: 7 | - ps: Vsix-IncrementVsixVersion | Vsix-UpdateBuildVersion 8 | #- ps: Vsix-TokenReplacement LocateFolder\source.extension.cs 'Version = "([0-9\\.]+)"' 'Version = "{version}"' 9 | 10 | build_script: 11 | - dotnet restore "EncodingNormalior\EncodingNormalior.csproj" 12 | - nuget restore -Verbosity quiet 13 | - msbuild /p:configuration=Release /p:DeployExtension=false /p:ZipPackageCompressionLevel=normal /v:m 14 | test: 15 | assemblies: 16 | only: 17 | - EncodingNormalizer.UnitTest -------------------------------------------------------------------------------- /build/Version.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 1.7.3 4 | 5 | --------------------------------------------------------------------------------