Skip to content

Commit ebaa62f

Browse files
committed
add --encoding with workspace character encoding
1 parent 590d1bf commit ebaa62f

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/org/phpsrc/eclipse/pti/tools/codesniffer/core/PHPCodeSniffer.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import org.apache.xerces.parsers.DOMParser;
1717
import org.eclipse.core.resources.IFile;
1818
import org.eclipse.core.resources.IProject;
19+
import org.eclipse.core.resources.ResourcesPlugin;
1920
import org.eclipse.core.runtime.CoreException;
2021
import org.eclipse.core.runtime.IPath;
2122
import org.eclipse.core.runtime.Path;
@@ -225,7 +226,7 @@ protected PHPToolLauncher getPHPToolLauncher(IProject project,
225226
.getSessionProperty(QUALIFIED_NAME);
226227
if (launcher != null) {
227228
launcher.setCommandLineArgs(getCommandLineArgs(standard,
228-
prefs.getTabWidth()));
229+
prefs.getTabWidth(), ResourcesPlugin.getEncoding()));
229230
return launcher;
230231
}
231232
} catch (CoreException e) {
@@ -234,7 +235,7 @@ protected PHPToolLauncher getPHPToolLauncher(IProject project,
234235

235236
launcher = new PHPToolLauncher(QUALIFIED_NAME,
236237
getPHPExecutable(prefs.getPhpExecutable()), getScriptFile(),
237-
getCommandLineArgs(standard, prefs.getTabWidth()),
238+
getCommandLineArgs(standard, prefs.getTabWidth(), ResourcesPlugin.getEncoding()),
238239
getPHPINIEntries(prefs, project, standard));
239240

240241
launcher.setPrintOuput(prefs.isPrintOutput());
@@ -279,7 +280,7 @@ public static IPath getScriptFile() {
279280
"/php/tools/phpcs.php");
280281
}
281282

282-
private String getCommandLineArgs(Standard standard, int tabWidth) {
283+
private String getCommandLineArgs(Standard standard, int tabWidth, String encoding) {
283284

284285
String args = "--report=xml --standard="
285286
+ (standard.custom ? OperatingSystem
@@ -289,6 +290,9 @@ private String getCommandLineArgs(Standard standard, int tabWidth) {
289290
if (tabWidth > 0)
290291
args += " --tab-width=" + tabWidth;
291292

293+
if (encoding != null && !encoding.isEmpty())
294+
args += " --encoding=" + encoding;
295+
292296
return args + " " + PHPToolLauncher.COMMANDLINE_PLACEHOLDER_FILE;
293297
}
294298
}

0 commit comments

Comments
 (0)