-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #60 from 0x78654C/v1.9.0.2
V1.9.0.2
- Loading branch information
Showing
12 changed files
with
211 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 81 additions & 0 deletions
81
Commands/TerminalCommands/ConsoleSystem/ConsoleEncoding.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
using Core; | ||
using System; | ||
using System.Runtime.Versioning; | ||
using System.Text; | ||
|
||
namespace Commands.TerminalCommands.ConsoleSystem | ||
{ | ||
[SupportedOSPlatform("windows")] | ||
public class ConsoleEncoding : ITerminalCommand | ||
{ | ||
public string Name => "enc"; | ||
private static string s_helpMessage = $@" Usage of enc command: | ||
enc defalut : Set input/output encoding to default .NET encoding. | ||
enc utf8 : Set input/output encoding to UTF8. | ||
enc unicode : Set input/output encoding to Unicode. | ||
enc ascii : Set input/output encoding to ASCII. | ||
enc -current : Show the current input/output encoding. | ||
Default input/output encoding for xTerminal is UTF-8. | ||
"; | ||
public void Execute(string arg) | ||
{ | ||
if (arg == Name) | ||
{ | ||
FileSystem.SuccessWriteLine("Use -h for more information!"); | ||
return; | ||
} | ||
|
||
arg = arg.Substring(3).Trim().ToLower(); | ||
|
||
// Display help message. | ||
if (arg.Trim() == "-h") | ||
{ | ||
Console.WriteLine(s_helpMessage); | ||
return; | ||
} | ||
|
||
if(arg == "-current") | ||
{ | ||
var encodingIn = Console.InputEncoding.EncodingName; | ||
var encodingOut = Console.OutputEncoding.EncodingName; | ||
var dataDisplay = $"Input encoding: {encodingIn}\nOutput encoding: {encodingOut}"; | ||
FileSystem.SuccessWriteLine(dataDisplay); | ||
return; | ||
} | ||
|
||
if (arg == "utf8") | ||
{ | ||
Console.InputEncoding = Encoding.UTF8; | ||
Console.OutputEncoding = Encoding.UTF8; | ||
FileSystem.SuccessWriteLine($"Console encoding set to: {Console.InputEncoding.EncodingName}"); | ||
return; | ||
} | ||
|
||
if (arg == "unicode") | ||
{ | ||
Console.InputEncoding = Encoding.Unicode; | ||
Console.OutputEncoding = Encoding.Unicode; | ||
FileSystem.SuccessWriteLine($"Console encoding set to: {Console.InputEncoding.EncodingName}"); | ||
return; | ||
} | ||
|
||
if (arg == "default") | ||
{ | ||
Console.InputEncoding = Encoding.Default; | ||
Console.OutputEncoding = Encoding.Default; | ||
FileSystem.SuccessWriteLine($"Console encoding set to: {Console.InputEncoding.EncodingName}"); | ||
return; | ||
} | ||
|
||
if (arg == "ascii") | ||
{ | ||
Console.InputEncoding = Encoding.ASCII; | ||
Console.OutputEncoding = Encoding.ASCII; | ||
FileSystem.SuccessWriteLine($"Console encoding set to: {Console.InputEncoding.EncodingName}"); | ||
return; | ||
} | ||
FileSystem.ErrorWriteLine("The encode type is not part of the lis. Use -h for more information!"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.