mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-30 17:24:08 +00:00
Mac-specific: Log possible errors in OpenCC library
This commit is contained in:
parent
dad18b8113
commit
10d56ea546
14
chinese.cc
14
chinese.cc
|
@ -44,6 +44,11 @@ CharacterConversionDictionary::CharacterConversionDictionary( std::string const
|
|||
try {
|
||||
#ifdef Q_OS_MAC
|
||||
converter = opencc_open( openccConfig.toLocal8Bit().constData() );
|
||||
if( converter == reinterpret_cast< opencc_t >( -1 ) )
|
||||
{
|
||||
gdWarning( "CharacterConversionDictionary: failed to initialize OpenCC from config %s: %s\n",
|
||||
openccConfig.toLocal8Bit().constData(), opencc_error() );
|
||||
}
|
||||
#else
|
||||
converter = new opencc::SimpleConverter( openccConfig.toLocal8Bit().constData() );
|
||||
#endif
|
||||
|
@ -80,8 +85,13 @@ std::vector< gd::wstring > CharacterConversionDictionary::getAlternateWritings(
|
|||
if ( converter != NULL && converter != reinterpret_cast< opencc_t >( -1 ) )
|
||||
{
|
||||
char * tmp = opencc_convert_utf8( converter, input.c_str(), input.length() );
|
||||
output = std::string( tmp );
|
||||
opencc_convert_utf8_free( tmp );
|
||||
if( tmp )
|
||||
{
|
||||
output = std::string( tmp );
|
||||
opencc_convert_utf8_free( tmp );
|
||||
}
|
||||
else
|
||||
gdWarning( "OpenCC: convertion failed %s\n", opencc_error() );
|
||||
}
|
||||
#else
|
||||
output = converter->Convert( input );
|
||||
|
|
Loading…
Reference in a new issue