Posts: 24
Joined: Apr 2008
Reputation:
0
I compiled svn code in XP with VC 2008 express. when I use it to play video, I find that the Chinese subtitle can't display. In log file, it says:
16:28:01 T:3664 M:371625984 ERROR: CCharsetConverter::convert failed
16:28:01 T:3664 M:371625984 ERROR: CCharsetConverter::convert failed
The linux version can decode correctly.
Posts: 2,745
Joined: Oct 2003
Reputation:
1
WiSo
Team-Kodi Developer
Posts: 2,745
We need the full debug log (pastebin) and a short example file to reproduce it.
Posts: 24
Joined: Apr 2008
Reputation:
0
I traced the program again, and find something intersting. the function "libiconv_t" always returns empty string.It seems that the main program can not call the fuction in the static lib "libiconv" or the libiconv can't work well. I guess there is something worng between the libiconv, the file"iconv.h", the file "CharsetConverter.h" and the find "CharsetConverter.cpp". I hope these will help to find out the problem.
Posts: 24
Joined: Apr 2008
Reputation:
0
I used a font combine with the YaHei font come from vista and the font MS Consolas so I can dispalyer the Chinese char and English char well. I replace the /Media/Font/arial.ttf with it. I am confused that it can show chinese char at UI, but can't show it in subtitle. I know there is some issue about this font, but I just use in myself. I copy from windows/fonts dir.
Posts: 24
Joined: Apr 2008
Reputation:
0
At last I found what was happened in the program. In xbmc/utils/CharsetConverter.cpp, it use the fuction CCharsetConverter::wToUTF8 to convert the UTF-16LE to UTF-8 encode, but in windows xp, the sizeof(wchar_t) return 2 rather then 4, so the iconv->convert functun can not work right. Just change line 319 in CharsetConverter.cpp from:
convert(m_iconvWtoUtf8,sizeof(wchar_t),WCHAR_CHARSET,"UTF-8",strSource,strDest);
to:
#if defined(_XBOX) || defined(WIN32)
convert(m_iconvWtoUtf8,sizeof(wchar_t) * 2,WCHAR_CHARSET,"UTF-8",strSource,strDest);
#else
convert(m_iconvWtoUtf8,sizeof(wchar_t),WCHAR_CHARSET,"UTF-8",strSource,strDest);
#endif
will worked perfectly. I am not sure if the sizeof(wchar_t) in other place should change.
I don't know how to submit the patch to the developer term. The sourceforge's tracker can access know.
Posts: 2,745
Joined: Oct 2003
Reputation:
1
WiSo
Team-Kodi Developer
Posts: 2,745
Thanks for the detailed report. The question is if we can do the change for all conversation routines? What I don't get is when windows defines wchar_t as 2 bytes why do we have to increase it to 4 bytes since we're on windows?
Also I read somewhere that windows uses utf-16 and most Linux OS utf-32 so what does this have to do with utf-8?
Posts: 26,215
Joined: Oct 2003
Reputation:
187
Multiplier IMO should be 6 in both cases. The multiplier is used for the number of bytes that the destination charset could potentially use. It's computed as the length of the input string (in characters, not bytes) times the multiplier.
UTF-8 can potentially use 6 bytes per character (in most cases it'll use 4 or less though). Setting the multiplier to sizeof(wchar_t) is certainly incorrect as this has nothing to do with the output charset of utf8. The reason it fails on win32 with chinese is because it's essentially using a multiplier of 2 which doesn't allocate enough bytes for the conversion.
Solution: Change anything that outputs in UTF8 to use 6.
Cheers,
Jonathan
Posts: 24
Joined: Apr 2008
Reputation:
0
I think using "sizeof(WCHAR_CHARSET)" is better solution then "sizeof( wchar_t) *2" since it has defined in CharsetConverter.h in different os.
Posts: 119
Joined: Feb 2008
Reputation:
0
Sorry I might be dense but, I am also having this problem on rev 13859 and I tried to follow kazuyuki fix but I can't find the utils folder\file under C:\Program Files\XBMC\ . I know this will be fixed but my wife hates MCE and is driving me crazy to get XBMC working and that's the only thing left to fix. Anyt help would be greatly appreciated.
Cheers
treefour
Asus Essentio CS5110, Intel E8300, 2 GB Ram, 8600M GT
Posts: 639
Joined: Feb 2004
Reputation:
0
Clumsy
Team-XBMC Forum Moderator
Posts: 639
You will have to wait for a new win32 release or compile yourself (which will probably not be worth the trouble, especially if you use kazuyukis fix, which is more of a workaround than a fix, because it is apparantly also using the wrong logic).