Skip to content

Commit

Permalink
Fix DeepSource CS-R1018
Browse files Browse the repository at this point in the history
  • Loading branch information
lc6464 committed Feb 19, 2024
1 parent 31838bc commit f1f3009
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
3 changes: 2 additions & 1 deletion Helpers.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
using System.Diagnostics.CodeAnalysis;
using System.Globalization;

namespace ConsoleHelpers;

public static class Helpers {
public static readonly string? debugEnv = Environment.GetEnvironmentVariable("Base16384_Net_Debug");
public static readonly bool DEBUG = debugEnv is not null && debugEnv.ToLower() is not "false" and not "0";
public static readonly bool DEBUG = debugEnv is not null && debugEnv.ToLower(new CultureInfo("en-US", false)) is not "false" and not "0";


public static int PrintErrorMessage(string? message, string? debugMessage = null, int exitCode = 0) {
Expand Down
19 changes: 17 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,27 @@ Base16384.Net <"e" | "d"> <source | "-"> [out | "-"]
- 编码
- `Base16384.Net.exe e C:\Users\lc6464\Desktop\test.mp4 C:\Users\lc6464\Desktop\test.mp4.txt`
- `$PSVersionTable.OS | Base16384.Net e - /root/os.txt`
- `Base16384.Net e "/home/lc6464/hello world.jpg" - > hw.txt`
- `Base16384.Net e "/home/lc6464/hello world.jpg" - > /dev/null`
- 解码
- `Base16384.Net.exe d C:\Users\lc6464\Desktop\test.encoded C:\Users\lc6464\Desktop\test.py`
- `Base16384.Net d /root/os.txt -`
- `Base16384.Net d /root/filesEncoded /home/lc6464/rawFiles`
- 测试
- `Base16384.Net.exe e C:\Users\lc6464\Desktop\test.mp4 - | Base16384.Net.exe d - C:\Users\lc6464\Desktop\test.mp4`
- `$PSVersionTable.OS | Base16384.Net e - | Base16384.Net d -`
- 调试:将环境变量 `Base16384_Net_Debug` 设为 `true` `1` 等值,可输出调试信息。特别注意,即使编解码到标准输出,也会输出异常信息!

## 出错时调试
将环境变量 `Base16384_Net_Debug` 设为 `true``1` 等值,可输出调试信息。<br/>
特别注意,即使编解码到标准输出,也会输出异常信息!<br/>
只要环境变量 `Base16384_Net_Debug` 存在,且转小写后不为 `false``0`,就会进入调试模式。

## 注意事项
UTF16BE 编码的文件需要 BOM,使用输出到文件时,会自动添加 BOM,<br/>
但输出到标准输出时,**不会**添加 BOM,因此强烈不建议在终端通过*标准输出*输出后直接*重定向*到文件!<br/>
如果需要输出到标准输出时通过其他软件或表达式处理后输出到文件,务必手动添加 BOM,否则可能导致兼容性问题!

另外,通过*标准输出*输出的结果是 UTF16BE 编码后的二进制数据,终端直接显示可能会乱码。

## 下载软件
- 可直接通过 [GitHub Release](https://github.com/lc6464/Base16384.Net/releases/latest) 下载。
- 克隆项目通过 Visual Studio 或 dotnet cli 自行编译。

0 comments on commit f1f3009

Please sign in to comment.