Closed tautcony closed 8 years ago
Currently it uses the encoding from the BencodeParser
.
I agree, though, that it would probably make sense to try and use the encoding specified in the torrent file itself. I'll look into it.
Well, thought I can pass the encoding to the BencodeParser
, but in some old torrent(eg: which I upload) may has different encoding in different fields, such as name
with GBK
and name.utf-8
with utf-8
(maybe keep the original data as BString
would be better?)
Please try out v2.2.1 from NuGet and see if you still have any issues.
It will now try to use the encoding from the torrent file itself, except if the dictionary key ends with utf-8
, then it will use UTF-8.
If the torrent does not specify an encoding it will fall back to the parser's encoding.
Although BencodeNET actually supports multiple encodings, when loading a non utf-8 encoded torrent, the process while parsing such as
ToString
in theParseSingleFileInfo
function, Does not use the encoding provided in the torrent but using the default utf-8 encoding to convert theBString
tostring
. After that, there is a process to set the encoding to each field, but the string has been lost some data irreversible.Another point, all fields in
ExtraFields
are not properly marked as given encoded, so that they are marked as utf-8.The sample has uploaded. GBK.torrent.zip