Skip to content

Commit

Permalink
Handle exception setting console encoding
Browse files Browse the repository at this point in the history
  • Loading branch information
maxim-zhao committed Dec 24, 2021
1 parent 37c1c16 commit ba6f118
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 12 deletions.
3 changes: 2 additions & 1 deletion LibSidWiz/LibSidWiz.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>LibSidWiz</RootNamespace>
<AssemblyName>LibSidWiz</AssemblyName>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
Expand Down
12 changes: 10 additions & 2 deletions LibSidWiz/Outputs/FfmpegOutput.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,16 @@ public FfmpegOutput(string pathToExe, string filename, int width, int height, in

Console.WriteLine($"Starting FFMPEG: {pathToExe} {arguments}");

// We don't want a BOM to be injected if the system code page is set to UTF-8
Console.InputEncoding = Encoding.ASCII;
// We don't want a BOM to be injected if the system code page is set to UTF-8.
// This fails sometimes, so we swallow the error...
try
{
Console.InputEncoding = Encoding.ASCII;
}
catch (Exception e)
{
Console.WriteLine($"Failed to change console encoding to ASCII. You may get video corruption. Exception said: {e.Message}");
}

// Start it up
_process = Process.Start(
Expand Down
2 changes: 1 addition & 1 deletion SidWiz/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion SidWiz/SidWizPlusGUI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>SidWizPlusGUI</RootNamespace>
<AssemblyName>SidWizPlusGUI</AssemblyName>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<TargetFrameworkProfile>
</TargetFrameworkProfile>
<FileAlignment>512</FileAlignment>
Expand Down
7 changes: 3 additions & 4 deletions SidWiz/app.config
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>

<configuration>
<runtime>
<gcAllowVeryLargeObjects enabled="true" />
<gcAllowVeryLargeObjects enabled="true"/>
<!-- AppContextSwitchOverrides value attribute is in the form of 'key1=true|false;key2=true|false -->
<AppContextSwitchOverrides value="Switch.UseLegacyAccessibilityFeatures=false" />
<AppContextSwitchOverrides value="Switch.UseLegacyAccessibilityFeatures=false"/>
</runtime>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8"/>
</startup>
</configuration>
2 changes: 1 addition & 1 deletion SidWizPlus/App.config
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2"/>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8"/>
</startup>
</configuration>
2 changes: 1 addition & 1 deletion SidWizPlus/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion SidWizPlus/SidWizPlus.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<OutputType>Exe</OutputType>
<RootNamespace>SidWizPlus</RootNamespace>
<AssemblyName>SidWizPlus</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
Expand Down

0 comments on commit ba6f118

Please sign in to comment.