Browse Source

fix rencode string length

Can not add magnet url to deluge through RPC interface
The rencode string length is wrong if magnet URL contents CJK utf8 string
Use byte length instead of string length
pull/596/head
Tao Guo 3 years ago committed by Tao Guo
parent
commit
c9ffcb6ef5
  1. 2
      app/src/main/java/se/dimovski/rencode/RencodeOutputStream.java

2
app/src/main/java/se/dimovski/rencode/RencodeOutputStream.java

@ -212,7 +212,7 @@ public class RencodeOutputStream extends FilterOutputStream implements DataOutpu
* Writes a {@link String} * Writes a {@link String}
*/ */
public void writeString(String value) throws IOException { public void writeString(String value) throws IOException {
int len = value.length(); int len = value.getBytes().length;
if (len < TypeCode.EMBEDDED.STR_COUNT) { if (len < TypeCode.EMBEDDED.STR_COUNT) {
write(TypeCode.EMBEDDED.STR_START + len); write(TypeCode.EMBEDDED.STR_START + len);
} else { } else {

Loading…
Cancel
Save