I am using this bencode https://github.com/dampcake/bencode to decode a torrent file. I am having an issue : the encoded torrent file looks something like this :
d8:announce21:http://127.0.0.1: ....etc..... piece lengthi65536e6:pieces28300:a�ډ|E���� ���#-14 .....etc........
The thing is that when I enter this string in the 'decoder', I get an error because of the � symbols. Here is my question: should I stop decoding just before those symbols ? Or is the whole string necessary to properly decode the .torrent file ?
From what I've read, I need to stop the decoding at the end of the dictionary, ie. when I encounter the final 'e', but I don't know how to properly identify it..
Thanks
UPDATE:
Here is my code :
byte[] to_decode = null;
try {
Path path = Paths.get("/user/.../file.torrent");
to_decode = Files.readAllBytes(path);
} catch (IOException e) {
System.out.println(e.toString());
}
//System.out.println(to_decode.toString());
Bencode bencode = new Bencode();
Map<String, Object> dict = bencode.decode(to_decode, Type.DICTIONARY);
System.out.println(dict);
When I run it, I have no errors but this kind of output:
f<�>�0�1FT���n" ......etc...... 4'}$�Q�3�� Җk�, private=0}}
So, considering the brackets, I think the output is a dictionary but not in a usable format, and I can't seem to make it work
Any advice ?