Fix 编码选择显示不对应问题
parent
2840c9a378
commit
534e5c0850
|
@ -10,12 +10,12 @@
|
|||
|
||||
// 新增:输出编码枚举
|
||||
enum class OutputEncoding {
|
||||
UTF8 = 0,
|
||||
AUTO_DETECT =0,
|
||||
UTF8,
|
||||
GBK,
|
||||
GB2312,
|
||||
BIG5,
|
||||
SHIFT_JIS,
|
||||
AUTO_DETECT
|
||||
};
|
||||
|
||||
class CLIProcess {
|
||||
|
@ -60,8 +60,8 @@ private:
|
|||
// 新增:编码转换相关方法
|
||||
std::string ConvertToUTF8(const std::string& input, OutputEncoding encoding);
|
||||
std::string DetectAndConvertToUTF8(const std::string& input);
|
||||
UINT GetCodePageFromEncoding(OutputEncoding encoding);
|
||||
bool IsValidUTF8(const std::string& str);
|
||||
static UINT GetCodePageFromEncoding(OutputEncoding encoding);
|
||||
static bool IsValidUTF8(const std::string& str);
|
||||
|
||||
PROCESS_INFORMATION pi_{};
|
||||
HANDLE hReadPipe_{};
|
||||
|
|
|
@ -30,7 +30,7 @@ OutputEncoding CLIProcess::GetOutputEncoding() const {
|
|||
}
|
||||
|
||||
// 新增:获取编码名称
|
||||
std::string CLIProcess::GetEncodingName(OutputEncoding encoding) {
|
||||
std::string CLIProcess::GetEncodingName(const OutputEncoding encoding) {
|
||||
switch (encoding) {
|
||||
case OutputEncoding::UTF8: return "UTF-8";
|
||||
case OutputEncoding::GBK: return "GBK";
|
||||
|
@ -55,9 +55,8 @@ std::vector<std::pair<OutputEncoding, std::string>> CLIProcess::GetSupportedEnco
|
|||
}
|
||||
|
||||
// 新增:根据编码获取代码页
|
||||
UINT CLIProcess::GetCodePageFromEncoding(OutputEncoding encoding) {
|
||||
UINT CLIProcess::GetCodePageFromEncoding(const OutputEncoding encoding) {
|
||||
switch (encoding) {
|
||||
case OutputEncoding::UTF8: return CP_UTF8;
|
||||
case OutputEncoding::GBK: return 936;
|
||||
case OutputEncoding::GB2312: return 20936;
|
||||
case OutputEncoding::BIG5: return 950;
|
||||
|
@ -68,7 +67,7 @@ UINT CLIProcess::GetCodePageFromEncoding(OutputEncoding encoding) {
|
|||
|
||||
// 新增:检查是否为有效的UTF-8
|
||||
bool CLIProcess::IsValidUTF8(const std::string& str) {
|
||||
const unsigned char* bytes = reinterpret_cast<const unsigned char*>(str.c_str());
|
||||
const auto* bytes = reinterpret_cast<const unsigned char*>(str.c_str());
|
||||
size_t len = str.length();
|
||||
|
||||
for (size_t i = 0; i < len; ) {
|
||||
|
|
|
@ -318,13 +318,8 @@ void Manager::RenderEnvironmentVariablesSettings() {
|
|||
ImGui::Unindent();
|
||||
} else {
|
||||
ImGui::BeginDisabled(true);
|
||||
ImGui::InputText("变量名", env_key_input_, IM_ARRAYSIZE(env_key_input_));
|
||||
ImGui::SameLine();
|
||||
ImGui::InputText("变量值", env_value_input_, IM_ARRAYSIZE(env_value_input_));
|
||||
ImGui::SameLine();
|
||||
ImGui::Button("添加");
|
||||
ImGui::EndDisabled();
|
||||
ImGui::TextWrapped("说明:禁用时将使用系统默认环境变量启动程序。");
|
||||
ImGui::EndDisabled();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue