Bug 341129 - Bidi3.4: Bidi strings are not displayed properly in Console view
diff --git a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/debug/model/RemoteAntDebugBuildListener.java b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/debug/model/RemoteAntDebugBuildListener.java
index 6ccb556..7137d46 100644
--- a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/debug/model/RemoteAntDebugBuildListener.java
+++ b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/debug/model/RemoteAntDebugBuildListener.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2003, 2006 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.ui/Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/AntLaunchDelegate.java b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/AntLaunchDelegate.java
index b7e35e9..4d32173 100644
--- a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/AntLaunchDelegate.java
+++ b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/AntLaunchDelegate.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2000, 2009 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
@@ -537,14 +537,15 @@
 	
 	private void runInSeparateVM(ILaunchConfiguration configuration, ILaunch launch, IProgressMonitor monitor, String idStamp, String antHome, int port, int requestPort, StringBuffer commandLine, boolean captureOutput, boolean setInputHandler) throws CoreException {
         boolean debug= fMode.equals(ILaunchManager.DEBUG_MODE);
+        String encoding = DebugPlugin.getDefault().getLaunchManager().getEncoding(configuration);
 		if (captureOutput) {
 			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.ui/Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/RemoteAntBuildListener.java b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/RemoteAntBuildListener.java
index 61d8136..c4fdb08 100644
--- a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/RemoteAntBuildListener.java
+++ b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/RemoteAntBuildListener.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- *  Copyright (c) 2003, 2008 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
@@ -72,6 +72,11 @@
     private String fLastFileName= null;
     private String fLastTaskName= null;
     private boolean fBuildFailed= false;
+    /**
+	 * The encoding to use
+	 * @since 3.5.2+
+	 */
+    private String fEncoding;
     
     /**
      * Reads the message stream from the RemoteAntBuildLogger
@@ -93,7 +98,7 @@
                 int socketTimeout= prefs.getInt(IAntUIPreferenceConstants.ANT_COMMUNICATION_TIMEOUT);
                 fServerSocket.setSoTimeout(socketTimeout);
                 fSocket= fServerSocket.accept();
-                fBufferedReader= new BufferedReader(new InputStreamReader(fSocket.getInputStream(), "UTF-8")); //$NON-NLS-1$
+                fBufferedReader= new BufferedReader(new InputStreamReader(fSocket.getInputStream(), fEncoding));
                 String message;
                 while(fBufferedReader != null && (message= fBufferedReader.readLine()) != null) {
                     receiveMessage(message);
@@ -112,12 +117,29 @@
         }
     }
     
-    public RemoteAntBuildListener(ILaunch launch) {
-        super();
-        fLaunch= launch;
-        DebugPlugin.getDefault().getLaunchManager().addLaunchListener(this);
+    /**
+	 * 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.5.2+
+	 */
+	protected String getEncoding() {
+		return fEncoding;
+	}
+	
     /**
      * Start listening to an Ant build. Start a server connection that
      * the RemoteAntBuildLogger can connect to.