[Zerofile-svn] SF.net SVN: zerofile: [78] trunk/src
Status: Pre-Alpha
Brought to you by:
karl-bengtsson
|
From: <kar...@us...> - 2007-12-13 13:42:16
|
Revision: 78
http://zerofile.svn.sourceforge.net/zerofile/?rev=78&view=rev
Author: karl-bengtsson
Date: 2007-12-13 05:42:14 -0800 (Thu, 13 Dec 2007)
Log Message:
-----------
maybe support for swedish characters
Modified Paths:
--------------
trunk/src/XMPPLinkLocalChatSession.java
trunk/src/ZeroFile.java
Modified: trunk/src/XMPPLinkLocalChatSession.java
===================================================================
--- trunk/src/XMPPLinkLocalChatSession.java 2007-12-13 11:30:42 UTC (rev 77)
+++ trunk/src/XMPPLinkLocalChatSession.java 2007-12-13 13:42:14 UTC (rev 78)
@@ -1,5 +1,8 @@
import java.io.*;
import java.net.*;
+import java.nio.*;
+import java.nio.charset.*;
+
import javax.swing.*;
/*
@@ -15,6 +18,8 @@
private PrintWriter _toRemoteHost;
private ZeroFileChatWindow _chatWindow;
private XMPPLinkLocalHost _chatPartner;
+ private Charset charset = Charset.forName("UTF-8");
+ private CharsetEncoder encoder = charset.newEncoder();
private HttpServer _httpServer = new HttpServer(this);
private Thread _remoteHostReadingThread = new Thread() {
@@ -62,8 +67,8 @@
fileTransferStanza += "<x xmlns=\"jabber:x:oob\">";
fileTransferStanza += "<url type=\"file\" size=\""+String.valueOf(sizeOfFile)+"\">";
fileTransferStanza += "http://"+InetAddress.getLocalHost().getHostAddress()+":"+_httpServer.getPort()+"/"+filnamn+"</url></x></message>";
- System.out.println(fileTransferStanza);
- _toRemoteHost.print(fileTransferStanza);
+ ByteBuffer bbuf = encoder.encode(CharBuffer.wrap(fileTransferStanza));
+ _toRemoteHost.print(bbuf);
_toRemoteHost.flush();
}
catch (Exception e)
@@ -80,7 +85,7 @@
{
_s = new Socket(hostToChatWith.getHost(),hostToChatWith.getPort());
_toRemoteHost = new PrintWriter(_s.getOutputStream());
- _fromRemoteHost = new InputStreamReader(_s.getInputStream());
+ _fromRemoteHost = new InputStreamReader(_s.getInputStream(),"UTF-8");
_remoteHostReadingThread.start();
sendHandshake();
}
@@ -202,9 +207,17 @@
public void sendMessage(String m)
{
- String messageStanza = "<message to=\""+_chatPartner.getServiceName()+"\" from=\""+ZeroconfRegistration.getMyServiceName()+"\"><body>"+m+"</body></message>";
- _toRemoteHost.print(messageStanza);
- _toRemoteHost.flush();
+ try
+ {
+ String messageStanza = "<message to=\""+_chatPartner.getServiceName()+"\" from=\""+ZeroconfRegistration.getMyServiceName()+"\"><body>"+m+"</body></message>";
+ ByteBuffer bbuf = encoder.encode(CharBuffer.wrap(messageStanza));
+ _toRemoteHost.print(bbuf);
+ _toRemoteHost.flush();
+ }
+ catch (Exception e)
+ {
+ System.out.println(e);
+ }
}
public void disconnect()
Modified: trunk/src/ZeroFile.java
===================================================================
--- trunk/src/ZeroFile.java 2007-12-13 11:30:42 UTC (rev 77)
+++ trunk/src/ZeroFile.java 2007-12-13 13:42:14 UTC (rev 78)
@@ -7,7 +7,6 @@
* @throws IOException
*/
public static void main(String[] args) throws IOException {
- System.out.println(InetAddress.getLocalHost().getHostAddress());
System.out.println(
new java.io.OutputStreamWriter(
new java.io.ByteArrayOutputStream()).getEncoding()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|