Skip to content
Snippets Groups Projects
Commit 754a608d authored by wilhelmhb's avatar wilhelmhb
Browse files

passage en utf-8

parent 547207b4
No related branches found
No related tags found
No related merge requests found
......@@ -33,7 +33,7 @@ public class UDP_Client {
d.socket().bind(new InetSocketAddress(0));
d.connect(new InetSocketAddress(ipAddr, 51117));
ByteBuffer b = ByteBuffer.allocate(1024);
byte[] s = Message.getBytes();
byte[] s = Message.getBytes("UTF-8");
for(byte c: s){
b.put(c);
}
......
......@@ -16,6 +16,7 @@ import java.net.SocketException;
import java.nio.ByteBuffer;
import java.nio.channels.DatagramChannel;
import java.nio.channels.FileChannel;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.security.MessageDigest;
......@@ -49,8 +50,10 @@ public class UDP_Server
try {
DatagramPacket receivePacket = new DatagramPacket(receiveData, receiveData.length);
serverSocket.receive(receivePacket);
String sentence = new String(receivePacket.getData());
sentence = sentence.split("\n")[0];
String sentence = new String(receivePacket.getData(), StandardCharsets.UTF_8);
sentence = sentence.split("~")[0];//TODO : deal with garbage
System.out.println("Message reçu : " + sentence);
try {
SmsManager smsManager = SmsManager.getDefault();
smsManager.sendTextMessage(nbPhone, null, sentence, null, null);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment