From c9ffcb6ef5947c70cb01b1d8e44587eb8a63cbb8 Mon Sep 17 00:00:00 2001 From: Tao Guo Date: Mon, 25 Oct 2021 15:49:27 +0800 Subject: [PATCH] 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 --- app/src/main/java/se/dimovski/rencode/RencodeOutputStream.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/se/dimovski/rencode/RencodeOutputStream.java b/app/src/main/java/se/dimovski/rencode/RencodeOutputStream.java index 335da987..48cb0e5c 100644 --- a/app/src/main/java/se/dimovski/rencode/RencodeOutputStream.java +++ b/app/src/main/java/se/dimovski/rencode/RencodeOutputStream.java @@ -212,7 +212,7 @@ public class RencodeOutputStream extends FilterOutputStream implements DataOutpu * Writes a {@link String} */ public void writeString(String value) throws IOException { - int len = value.length(); + int len = value.getBytes().length; if (len < TypeCode.EMBEDDED.STR_COUNT) { write(TypeCode.EMBEDDED.STR_START + len); } else {