diff --git a/platform/platform-api/src/com/intellij/execution/configurations/EncodingEnvironmentUtil.java b/platform/platform-api/src/com/intellij/execution/configurations/EncodingEnvironmentUtil.java
index d728cab1b188..f24f9f7def63 100644
--- a/platform/platform-api/src/com/intellij/execution/configurations/EncodingEnvironmentUtil.java
+++ b/platform/platform-api/src/com/intellij/execution/configurations/EncodingEnvironmentUtil.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2014 JetBrains s.r.o.
+ * Copyright 2000-2015 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,22 +16,17 @@
package com.intellij.execution.configurations;
import com.intellij.openapi.diagnostic.Logger;
-import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.SystemInfo;
-import com.intellij.openapi.vfs.encoding.EncodingManager;
-import com.intellij.openapi.vfs.encoding.EncodingProjectManager;
import com.intellij.util.EnvironmentUtil;
-import com.intellij.util.PlatformUtils;
import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
import java.nio.charset.Charset;
import java.util.Locale;
import java.util.Map;
public class EncodingEnvironmentUtil {
-
private static final Logger LOG = Logger.getInstance(EncodingEnvironmentUtil.class);
+
private static final String LC_ALL = "LC_ALL";
private static final String LC_CTYPE = "LC_CTYPE";
private static final String LANG = "LANG";
@@ -43,7 +38,7 @@ public class EncodingEnvironmentUtil {
*
* Unfortunately, Mac OSX has a special behavior:
* These environment variables aren't passed to an IDE, if the IDE is launched from Spotlight.
- * Unfortunately, even {@link com.intellij.util.EnvironmentUtil#getEnvironment()} doesn't have these variables.
+ * Unfortunately, even {@link EnvironmentUtil#getEnvironment()} doesn't have these variables.
* As a result, no encoding environment variables are passed to Ruby/Node.js/Python/other processes that are launched from IDE.
* Thus, these processes wrongly assume that the default encoding is US-ASCII.
*
@@ -54,22 +49,17 @@ public class EncodingEnvironmentUtil {
* @param commandLine GeneralCommandLine instance
*/
public static void setLocaleEnvironmentIfMac(@NotNull GeneralCommandLine commandLine) {
- if (SystemInfo.isMac) {
- if (!isLocaleDefined(commandLine)) {
- setLocaleEnvironment(commandLine.getEnvironment(), commandLine.getCharset());
- }
+ if (SystemInfo.isMac && !isLocaleDefined(commandLine)) {
+ setLocaleEnvironment(commandLine.getEnvironment(), commandLine.getCharset());
}
}
/**
- * @deprecated Use {@link #setLocaleEnvironmentIfMac(GeneralCommandLine)} instead. To be removed in IDEA 15.
+ * Sets default encoding on Mac if it's undefined.
*/
- @Deprecated
- public static void fixDefaultEncodingIfMac(@NotNull GeneralCommandLine commandLine, @Nullable Project project) {
- if (SystemInfo.isMac) {
- if (!isLocaleDefined(commandLine)) {
- setLocaleEnvironment(commandLine.getEnvironment(), getCharset(project));
- }
+ public static void setLocaleEnvironmentIfMac(@NotNull Map env, @NotNull Charset charset) {
+ if (SystemInfo.isMac && !isLocaleDefined(env)) {
+ setLocaleEnvironment(env, charset);
}
}
@@ -85,65 +75,15 @@ public class EncodingEnvironmentUtil {
Locale locale = Locale.getDefault();
String language = locale.getLanguage();
String country = locale.getCountry();
- if (language.isEmpty() || country.isEmpty()) {
- return "en_US." + charset.name();
- }
- return language + "_" + country + "." + charset.name();
- }
-
- /**
- * Sets default encoding on Mac if it's undefined.
- * @deprecated Use {@link #setLocaleEnvironmentIfMac(java.util.Map, java.nio.charset.Charset)} instead. To be removed in IDEA 15.
- */
- @Deprecated
- public static void fixDefaultEncodingIfMac(@NotNull Map env, @Nullable Project project) {
- if (SystemInfo.isMac) {
- if (!isLocaleDefined(env)) {
- setLocaleEnvironment(env, getCharset(project));
- }
- }
- }
-
- /**
- * Sets default encoding on Mac if it's undefined.
- */
- public static void setLocaleEnvironmentIfMac(@NotNull Map env, @NotNull Charset charset) {
- if (SystemInfo.isMac) {
- if (!isLocaleDefined(env)) {
- setLocaleEnvironment(env, charset);
- }
- }
+ return (language.isEmpty() || country.isEmpty() ? "en_US" : language + "_" + country) + "." + charset.name();
}
private static boolean isLocaleDefined(@NotNull GeneralCommandLine commandLine) {
- Map env = commandLine.getEnvironment();
- if (isLocaleDefined(env)) {
- return true;
- }
- if (commandLine.isPassParentEnvironment()) {
- // 'parentEnv' calculation logic should be kept in sync with GeneralCommandLine.setupEnvironment
- Map parentEnv = PlatformUtils.isAppCode() ? System.getenv() // Temporarily fix for OC-8606
- : EnvironmentUtil.getEnvironmentMap();
- if (isLocaleDefined(parentEnv)) {
- return true;
- }
- }
- return false;
+ return isLocaleDefined(commandLine.getEnvironment()) ||
+ commandLine.isPassParentEnvironment() && isLocaleDefined(commandLine.getParentEnvironment());
}
private static boolean isLocaleDefined(@NotNull Map env) {
return env.containsKey(LC_ALL) || env.containsKey(LC_CTYPE) || env.containsKey(LANG);
}
-
- @NotNull
- private static Charset getCharset(@Nullable Project project) {
- Charset charset;
- if (project == null) {
- charset = EncodingManager.getInstance().getDefaultCharset();
- }
- else {
- charset = EncodingProjectManager.getInstance(project).getDefaultCharset();
- }
- return charset;
- }
}
diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/commandLine/CommandExecutor.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/commandLine/CommandExecutor.java
index 71bca4152130..74e416eb29cb 100644
--- a/plugins/svn4idea/src/org/jetbrains/idea/svn/commandLine/CommandExecutor.java
+++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/commandLine/CommandExecutor.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2015 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -158,7 +158,7 @@ public class CommandExecutor {
}
protected void beforeCreateProcess() throws SvnBindException {
- EncodingEnvironmentUtil.fixDefaultEncodingIfMac(myCommandLine, null);
+ EncodingEnvironmentUtil.setLocaleEnvironmentIfMac(myCommandLine);
setupLocale();
ensureMessageFile();
ensureTargetsAdded();
diff --git a/python/src/com/jetbrains/python/console/PydevConsoleRunner.java b/python/src/com/jetbrains/python/console/PydevConsoleRunner.java
index cf7659fcf975..d17062befeb3 100644
--- a/python/src/com/jetbrains/python/console/PydevConsoleRunner.java
+++ b/python/src/com/jetbrains/python/console/PydevConsoleRunner.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2014 JetBrains s.r.o.
+ * Copyright 2000-2015 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -446,10 +446,9 @@ public class PydevConsoleRunner extends AbstractConsoleRunnerWithHistory envs = myCommandLineArgumentsProvider.getAdditionalEnvs();
if (envs != null) {
- EncodingEnvironmentUtil.fixDefaultEncodingIfMac(envs, getProject());
+ EncodingEnvironmentUtil.setLocaleEnvironmentIfMac(envs, EncodingProjectManager.getInstance(getProject()).getDefaultCharset());
}
- final Process server = ProcessRunner
- .createProcess(getWorkingDir(), envs, myCommandLineArgumentsProvider.getArguments());
+ Process server = ProcessRunner.createProcess(getWorkingDir(), envs, myCommandLineArgumentsProvider.getArguments());
try {
myPydevConsoleCommunication = new PydevConsoleCommunication(getProject(), myPorts[0], server, myPorts[1]);
}