Bug 341131 - Bidi3.4: Bidi strings are not displayed properly in Console view
diff --git a/ant/org.eclipse.ant.launching/src/org/eclipse/ant/internal/launching/debug/model/RemoteAntDebugBuildListener.java b/ant/org.eclipse.ant.launching/src/org/eclipse/ant/internal/launching/debug/model/RemoteAntDebugBuildListener.java
index 6d86b7a..3175fff 100644
--- a/ant/org.eclipse.ant.launching/src/org/eclipse/ant/internal/launching/debug/model/RemoteAntDebugBuildListener.java
+++ b/ant/org.eclipse.ant.launching/src/org/eclipse/ant/internal/launching/debug/model/RemoteAntDebugBuildListener.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2003, 2009 IBM Corporation and others.
+ * Copyright (c) 2003, 2011 IBM Corporation and others.
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License v1.0
  * which accompanies this distribution, and is available at
@@ -69,8 +69,14 @@
 		}
 	}	
 	
-	public RemoteAntDebugBuildListener(ILaunch launch) {
-		super(launch);
+	/**
+	 * Constructor
+	 * 
+	 * @param launch the backing launch to listen to
+	 * @param encoding the encoding to use for communications
+	 */
+	public RemoteAntDebugBuildListener(ILaunch launch, String encoding) {
+		super(launch, encoding);
 		//fDebug= true;
 	}
 	
@@ -130,7 +136,7 @@
     		try {
     			fRequestSocket = new Socket("localhost", fRequestPort); //$NON-NLS-1$
     			fRequestWriter = new PrintWriter(fRequestSocket.getOutputStream(), true);
-    			fResponseReader = new BufferedReader(new InputStreamReader(fRequestSocket.getInputStream()));
+    			fResponseReader = new BufferedReader(new InputStreamReader(fRequestSocket.getInputStream(), getEncoding()));
     			
     			fReaderThread= new ReaderThread();
     			fReaderThread.start();
diff --git a/ant/org.eclipse.ant.launching/src/org/eclipse/ant/internal/launching/launchConfigurations/AntLaunchDelegate.java b/ant/org.eclipse.ant.launching/src/org/eclipse/ant/internal/launching/launchConfigurations/AntLaunchDelegate.java
index 15088ae..3662460 100644
--- a/ant/org.eclipse.ant.launching/src/org/eclipse/ant/internal/launching/launchConfigurations/AntLaunchDelegate.java
+++ b/ant/org.eclipse.ant.launching/src/org/eclipse/ant/internal/launching/launchConfigurations/AntLaunchDelegate.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2000, 2010 IBM Corporation and others.
+ * Copyright (c) 2000, 2011 IBM Corporation and others.
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License v1.0
  * which accompanies this distribution, and is available at
@@ -597,15 +597,14 @@
 			boolean setInputHandler) throws CoreException {
 		boolean debug = fMode.equals(ILaunchManager.DEBUG_MODE);
 		if (captureOutput) {
+			String encoding = DebugPlugin.getDefault().getLaunchManager().getEncoding(configuration);
 			if (debug) {
-				RemoteAntDebugBuildListener listener = new RemoteAntDebugBuildListener(
-						launch);
+				RemoteAntDebugBuildListener listener = new RemoteAntDebugBuildListener(launch, encoding);
 				if (requestPort != -1) {
 					listener.startListening(port, requestPort);
 				}
 			} else if (!fUserSpecifiedLogger) {
-				RemoteAntBuildListener client = new RemoteAntBuildListener(
-						launch);
+				RemoteAntBuildListener client = new RemoteAntBuildListener(launch, encoding);
 				if (port != -1) {
 					client.startListening(port);
 				}
diff --git a/ant/org.eclipse.ant.launching/src/org/eclipse/ant/internal/launching/launchConfigurations/RemoteAntBuildListener.java b/ant/org.eclipse.ant.launching/src/org/eclipse/ant/internal/launching/launchConfigurations/RemoteAntBuildListener.java
index 2191556..a3a5c7d 100644
--- a/ant/org.eclipse.ant.launching/src/org/eclipse/ant/internal/launching/launchConfigurations/RemoteAntBuildListener.java
+++ b/ant/org.eclipse.ant.launching/src/org/eclipse/ant/internal/launching/launchConfigurations/RemoteAntBuildListener.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- *  Copyright (c) 2003, 2009 IBM Corporation and others.
+ *  Copyright (c) 2003, 2011 IBM Corporation and others.
  *  All rights reserved. This program and the accompanying materials
  *  are made available under the terms of the Eclipse Public License v1.0
  *  which accompanies this distribution, and is available at
@@ -61,6 +61,11 @@
 	private String fLastFileName = null;
 	private String fLastTaskName = null;
 	private boolean fBuildFailed = false;
+	/**
+	 * The encoding to use
+	 * @since 3.6.2+
+	 */
+	private String fEncoding;
 
 	/**
 	 * Reads the message stream from the RemoteAntBuildLogger
@@ -88,7 +93,7 @@
 				fServerSocket.setSoTimeout(socketTimeout);
 				fSocket = fServerSocket.accept();
 				fBufferedReader = new BufferedReader(new InputStreamReader(
-						fSocket.getInputStream(), "UTF-8")); //$NON-NLS-1$
+						fSocket.getInputStream(), fEncoding));
 				String message;
 				while (fBufferedReader != null
 						&& (message = fBufferedReader.readLine()) != null) {
@@ -108,12 +113,29 @@
 		}
 	}
 
-	public RemoteAntBuildListener(ILaunch launch) {
+	/**
+	 * Constructor
+	 * 
+	 * @param launch the backing launch to listen to
+	 * @param encoding the encoding to use for communications
+	 */
+	public RemoteAntBuildListener(ILaunch launch, String encoding) {
 		super();
 		fLaunch = launch;
+		fEncoding = encoding;
 		DebugPlugin.getDefault().getLaunchManager().addLaunchListener(this);
 	}
-
+	
+	/**
+	 * Returns the encoding set on the listener
+	 * 
+	 * @return the encoding set on the listener
+	 * @since 3.6.2+
+	 */
+	protected String getEncoding() {
+		return fEncoding;
+	}
+	
 	/**
 	 * Start listening to an Ant build. Start a server connection that the
 	 * RemoteAntBuildLogger can connect to.