mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-30 21:34:07 +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 {
|
try {
|
||||||
#ifdef Q_OS_MAC
|
#ifdef Q_OS_MAC
|
||||||
converter = opencc_open( openccConfig.toLocal8Bit().constData() );
|
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
|
#else
|
||||||
converter = new opencc::SimpleConverter( openccConfig.toLocal8Bit().constData() );
|
converter = new opencc::SimpleConverter( openccConfig.toLocal8Bit().constData() );
|
||||||
#endif
|
#endif
|
||||||
|
@ -80,8 +85,13 @@ std::vector< gd::wstring > CharacterConversionDictionary::getAlternateWritings(
|
||||||
if ( converter != NULL && converter != reinterpret_cast< opencc_t >( -1 ) )
|
if ( converter != NULL && converter != reinterpret_cast< opencc_t >( -1 ) )
|
||||||
{
|
{
|
||||||
char * tmp = opencc_convert_utf8( converter, input.c_str(), input.length() );
|
char * tmp = opencc_convert_utf8( converter, input.c_str(), input.length() );
|
||||||
output = std::string( tmp );
|
if( tmp )
|
||||||
opencc_convert_utf8_free( tmp );
|
{
|
||||||
|
output = std::string( tmp );
|
||||||
|
opencc_convert_utf8_free( tmp );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
gdWarning( "OpenCC: convertion failed %s\n", opencc_error() );
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
output = converter->Convert( input );
|
output = converter->Convert( input );
|
||||||
|
|
Loading…
Reference in a new issue