From d25ebe39ca265630b65a8c2ef35e80aa7da1da59 Mon Sep 17 00:00:00 2001 From: Tao Guo Date: Tue, 26 Oct 2021 11:32:53 +0800 Subject: [PATCH] fix charset when get 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 48cb0e5c..cfee5809 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.getBytes().length; + int len = value.getBytes(charset).length; if (len < TypeCode.EMBEDDED.STR_COUNT) { write(TypeCode.EMBEDDED.STR_START + len); } else {