Skip to content

Commit 0ef8851

Browse files
committed
Fix encoding on locales with non-arabic digits (as Hindi (India))
1 parent 9d1b339 commit 0ef8851

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/main/java/com/dampcake/bencode/BencodeOutputStream.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,13 +126,13 @@ public void writeDictionary(final Map<?, ?> m) throws IOException {
126126
private static String encode(final String s) {
127127
if (s == null) throw new NullPointerException("s cannot be null");
128128

129-
return String.format("%d%s%s", s.length(), Bencode.SEPARATOR, s);
129+
return String.format("%s%s%s", Integer.toString(s.length()), Bencode.SEPARATOR, s);
130130
}
131131

132132
private static String encode(final Number n) {
133133
if (n == null) throw new NullPointerException("n cannot be null");
134134

135-
return String.format("%s%d%s", Bencode.NUMBER, n.longValue(), Bencode.TERMINATOR);
135+
return String.format("%s%s%s", Bencode.NUMBER, Long.toString(n.longValue()), Bencode.TERMINATOR);
136136
}
137137

138138
private static String encode(final Iterable<?> l) {

0 commit comments

Comments
 (0)