mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-08 15:09:39 +07:00
Fix IDEA-228371: use UTF-8 for WinProcessListHelper output
GitOrigin-RevId: 79af877e65887e2f89f753e9e313729d94d5870b
This commit is contained in:
committed by
intellij-monorepo-bot
parent
1574e05d22
commit
6e290f092a
Binary file not shown.
@@ -5,6 +5,8 @@ using namespace std;
|
||||
#include <comdef.h>
|
||||
#include <Wbemidl.h>
|
||||
#include <string>
|
||||
#include <io.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#pragma comment(lib, "wbemuuid.lib")
|
||||
|
||||
@@ -29,6 +31,8 @@ wstring escapeLineBreaks(const wstring& str)
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
_setmode(_fileno(stdout), _O_U8TEXT);
|
||||
|
||||
HRESULT hres;
|
||||
|
||||
// Step 1: --------------------------------------------------
|
||||
|
||||
@@ -20,6 +20,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.*;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
@@ -73,9 +74,19 @@ public final class ProcessListUtil {
|
||||
@Nullable
|
||||
private static List<ProcessInfo> parseCommandOutput(@NotNull List<String> command,
|
||||
@NotNull NullableFunction<? super String, ? extends List<ProcessInfo>> parser) {
|
||||
return parseCommandOutput(command, parser, null);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static List<ProcessInfo> parseCommandOutput(@NotNull List<String> command,
|
||||
@NotNull NullableFunction<? super String, ? extends List<ProcessInfo>> parser,
|
||||
@Nullable Charset charset) {
|
||||
String output;
|
||||
try {
|
||||
ProcessOutput processOutput = ExecUtil.execAndGetOutput(new GeneralCommandLine(command));
|
||||
GeneralCommandLine commandLine = new GeneralCommandLine(command);
|
||||
if (charset != null)
|
||||
commandLine.withCharset(charset);
|
||||
ProcessOutput processOutput = ExecUtil.execAndGetOutput(commandLine);
|
||||
int exitCode = processOutput.getExitCode();
|
||||
if (exitCode != 0) {
|
||||
LOG.error("Cannot get process list, command '" + StringUtil.join(command, " ") +"' exited with code " + exitCode + ", stdout:\n"
|
||||
@@ -265,7 +276,7 @@ public final class ProcessListUtil {
|
||||
if (exeFile == null) {
|
||||
return null;
|
||||
}
|
||||
return parseCommandOutput(Collections.singletonList(exeFile.getAbsolutePath()), ProcessListUtil::parseWinProcessListHelperOutput);
|
||||
return parseCommandOutput(Collections.singletonList(exeFile.getAbsolutePath()), ProcessListUtil::parseWinProcessListHelperOutput, StandardCharsets.UTF_8);
|
||||
}
|
||||
|
||||
private static void logErrorTestSafe(String message) {
|
||||
|
||||
Reference in New Issue
Block a user