Skip to content

Commit 9ad06c2

Browse files
author
mInTRuns
committed
update ut8 charset support
1 parent cb727b4 commit 9ad06c2

File tree

4 files changed

+7
-4
lines changed

4 files changed

+7
-4
lines changed

src/de/javasocketapi/core/Client.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public void connect() throws IOException {
4141
this.socket = new Socket(this.hostname, this.port);
4242
this.socket.setTcpNoDelay(true);
4343
this.socket.setKeepAlive(true);
44-
this.socket.setPerformancePreferences(0, 1, 2);
44+
//this.socket.setPerformancePreferences(0, 1, 2);
4545
}
4646
//start reading and writing
4747
this.inputStreamThread = new InputStreamThread(this);

src/de/javasocketapi/core/ReadingByteBuffer.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package de.javasocketapi.core;
22

33
import java.nio.ByteBuffer;
4+
import java.nio.charset.StandardCharsets;
45
import java.util.UUID;
56

67
public class ReadingByteBuffer {
@@ -17,6 +18,7 @@ public boolean readBoolean() {
1718

1819
public byte readByte() {
1920
//read byte
21+
2022
return this.byteBuffer.get();
2123
}
2224

@@ -57,7 +59,7 @@ public String readString() {
5759
for (int i = 0; i < length; i++) {
5860
bytes[i] = this.readByte();
5961
}
60-
return new String(bytes);
62+
return new String(bytes, StandardCharsets.UTF_8);
6163
}
6264

6365
public UUID readUUID() {

src/de/javasocketapi/core/Server.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public void connect() throws IOException {
2525
if (this.serverSocket == null) {
2626
//initialise serverSocket
2727
this.serverSocket = new ServerSocket(this.port);
28-
this.serverSocket.setPerformancePreferences(0, 1, 2);
28+
//this.serverSocket.setPerformancePreferences(0, 1, 2);
2929
}
3030
//start accepting clients
3131
this.serverSocketAcceptingThread = new ServerSocketAcceptingThread(this.serverSocket);

src/de/javasocketapi/core/WritingByteBuffer.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import org.boon.primitive.ByteBuf;
44

5+
import java.nio.charset.StandardCharsets;
56
import java.util.UUID;
67

78
public class WritingByteBuffer {
@@ -55,7 +56,7 @@ public void writeString(final String value) {
5556
//check value
5657
WritingByteBuffer.checkInput(value);
5758
//writing string
58-
final byte[] bytes = value.getBytes();
59+
final byte[] bytes = value.getBytes(StandardCharsets.UTF_8);
5960
this.writeInt(bytes.length);
6061
for (final byte b : bytes) {
6162
this.writeByte(b);

0 commit comments

Comments
 (0)