CiccioBastardo, on Aug 20 2008, 02:06 AM, said:
Just for the statistics, I have integrated this patch into last Bastard version.
It doesn't hurt even in Win95+FAT, you at most "waste" a few bytes in the known.met file, so IMHO there's no point in arguing if it is valid or not.
eMule was thought to be Unicode compatible. This is is surely a part that was not updated for that. Creating problem on real Unicode supporting systems. Now it works correctly.
Thank Borschtsch.
Thank you.
There is one thing I am thinking about. Function NeedUTF8String() is called by WriteOptED2KUTF8Tag() and not only when saving known.met
It is called also when we save friend list, partfiles or server list.
partfile.cpp
SavePartFile()
{
...
if (WriteOptED2KUTF8Tag(&file, GetFileName(), FT_FILENAME))
uTagCount++;
CTag nametag(FT_FILENAME, GetFileName());
nametag.WriteTagToFile(&file);
...
}
Should we also change this part? It looks reasonable to do it.
SavePartFile()
{
...
if (WriteOptED2KUTF8Tag(&file, GetFileName(), FT_FILENAME))
uTagCount++;
CTag nametag(FT_FILENAME, GetFileName());
/*
nametag.WriteTagToFile(&file);
*/
nametag.WriteTagToFile(file, utf8strOptBOM);
...
}
But...
I made further investigation.
Let us think that we didn't make any changes in the code
if (WriteOptED2KUTF8Tag(file, GetFileName(), FT_FILENAME))
uTagCount++;
CTag nametag(FT_FILENAME, GetFileName());
nametag.WriteTagToFile(file);
uTagCount++;
If function NeedUTF8String() returns true then we can virtually expand WriteOptED2KUTF8Tag() and code may look like
...
CTag tag(FT_FILENAME, GetFileName());
tag.WriteTagToFile(file, utf8strOptBOM);
uTagCount++;
CTag nametag(FT_FILENAME, GetFileName());
nametag.WriteTagToFile(file);
uTagCount++;
...
So we write FT_FILENAME in known.met two times in the code, but it doesn't hurt at this moment because when we call LoadTagsFromFile() this part prevents us from discarding of the UTF-8 value
case FT_FILENAME:{
ASSERT( newtag->IsStr() );
if (newtag->IsStr()){
-->> if (GetFileName().IsEmpty())
-->> SetFileName(newtag->GetStr());
}
delete newtag;
break;
}
According to the latest discovered information the part of a patch in knownfile.cpp may look like this
KnownFile.cpp
bool CKnownFile::WriteToFile(CFileDataIO* file)
{
...
...
/* Borschtsch - we always save file name using UTF8
* Helps to eliminate re-hashing of files with
* the "wrong" symbols in their names
if (WriteOptED2KUTF8Tag(file, GetFileName(), FT_FILENAME))
uTagCount++;
CTag nametag(FT_FILENAME, GetFileName());
nametag.WriteTagToFile(file);
*/
CTag nametag(FT_FILENAME, GetFileName());
nametag.WriteTagToFile(file, utf8strOptBOM);
...
}
But now I have concerns about another thing.
Function LoadTagsFromFile() reads all tags using CTag::CTag(CFileDataIO* data, bool bOptUTF8). bOptUTF8 is
false in the code.
Patch works, no complains for more than a year, but how then UTF-8 values are being read from known.met? Do we want to set bOptUTF8 to true?
Any comments?