mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-27 15:24:05 +00:00
optimize: wchar use builtin char32_t
optimize: wchar use builtin char32_t
This commit is contained in:
parent
1d1e98b7ba
commit
b652d50291
|
@ -450,8 +450,8 @@ QString const& DictdDictionary::getDescription()
|
|||
if( !dictionaryDescription.isEmpty() )
|
||||
return dictionaryDescription;
|
||||
|
||||
sptr< Dictionary::DataRequest > req = getArticle( GD_NATIVE_TO_WS( L"00databaseinfo" ),
|
||||
vector< wstring >(), wstring(), false );
|
||||
sptr< Dictionary::DataRequest > req =
|
||||
getArticle( U"00databaseinfo" , vector< wstring >(), wstring(), false );
|
||||
|
||||
if( req->dataSize() > 0 )
|
||||
dictionaryDescription = Html::unescape( QString::fromUtf8( req->getFullData().data(), req->getFullData().size() ), true );
|
||||
|
|
118
dsl.cc
118
dsl.cc
|
@ -580,7 +580,7 @@ void DslDictionary::loadArticle( uint32_t address,
|
|||
if ( !articleBody )
|
||||
{
|
||||
// throw exCantReadFile( getDictionaryFilenames()[ 0 ] );
|
||||
articleData = GD_NATIVE_TO_WS( L"\n\r\t" ) + gd::toWString( QString( "DICTZIP error: " ) + dict_error_str( dz ) );
|
||||
articleData = U"\n\r\t" + gd::toWString( QString( "DICTZIP error: " ) + dict_error_str( dz ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -616,7 +616,7 @@ void DslDictionary::loadArticle( uint32_t address,
|
|||
{
|
||||
size_t begin = pos;
|
||||
|
||||
pos = articleData.find_first_of( GD_NATIVE_TO_WS( L"\n\r" ), begin );
|
||||
pos = articleData.find_first_of( U"\n\r" , begin );
|
||||
|
||||
if ( pos == wstring::npos )
|
||||
pos = articleData.size();
|
||||
|
@ -741,7 +741,7 @@ void DslDictionary::loadArticle( uint32_t address,
|
|||
if( insidedCard )
|
||||
{
|
||||
// Check for next insided headword
|
||||
wstring::size_type hpos = articleData.find_first_of( GD_NATIVE_TO_WS( L"\n\r" ), pos );
|
||||
wstring::size_type hpos = articleData.find_first_of( U"\n\r" , pos );
|
||||
if ( hpos == wstring::npos )
|
||||
hpos = articleData.size();
|
||||
|
||||
|
@ -820,13 +820,11 @@ string DslDictionary::nodeToHtml( ArticleDom::Node const & node )
|
|||
return result;
|
||||
}
|
||||
|
||||
if ( node.tagName == GD_NATIVE_TO_WS( L"b" ) )
|
||||
if( node.tagName == U"b" )
|
||||
result += "<b class=\"dsl_b\">" + processNodeChildren( node ) + "</b>";
|
||||
else
|
||||
if ( node.tagName == GD_NATIVE_TO_WS( L"i" ) )
|
||||
else if( node.tagName == U"i" )
|
||||
result += "<i class=\"dsl_i\">" + processNodeChildren( node ) + "</i>";
|
||||
else
|
||||
if ( node.tagName == GD_NATIVE_TO_WS( L"u" ) )
|
||||
else if( node.tagName == U"u" )
|
||||
{
|
||||
string nodeText = processNodeChildren( node );
|
||||
|
||||
|
@ -836,39 +834,32 @@ string DslDictionary::nodeToHtml( ArticleDom::Node const & node )
|
|||
|
||||
result += "<span class=\"dsl_u\">" + nodeText + "</span>";
|
||||
}
|
||||
else
|
||||
if ( node.tagName == GD_NATIVE_TO_WS( L"c" ) )
|
||||
else if( node.tagName == U"c" )
|
||||
{
|
||||
result += "<font color=\"" + ( node.tagAttrs.size() ?
|
||||
Html::escape( Utf8::encode( node.tagAttrs ) ) : string( "c_default_color" ) )
|
||||
+ "\">" + processNodeChildren( node ) + "</font>";
|
||||
}
|
||||
else
|
||||
if ( node.tagName == GD_NATIVE_TO_WS( L"*" ) )
|
||||
else if( node.tagName == U"*" )
|
||||
{
|
||||
string id = "O" + getId().substr( 0, 7 ) + "_" +
|
||||
QString::number( articleNom ).toStdString() +
|
||||
"_opt_" + QString::number( optionalPartNom++ ).toStdString();
|
||||
result += "<span class=\"dsl_opt\" id=\"" + id + "\">" + processNodeChildren( node ) + "</span>";
|
||||
}
|
||||
else
|
||||
if ( node.tagName == GD_NATIVE_TO_WS( L"m" ) )
|
||||
result += "<div class=\"dsl_m\">" + processNodeChildren( node ) + "</div>";
|
||||
else if( node.tagName == U"m" )
|
||||
result += "<div class=\"dsl_m\">" + processNodeChildren( node ) + "</div>";
|
||||
else
|
||||
if ( node.tagName.size() == 2 && node.tagName[ 0 ] == L'm' &&
|
||||
iswdigit( node.tagName[ 1 ] ) )
|
||||
result += "<div class=\"dsl_" + Utf8::encode( node.tagName ) + "\">" + processNodeChildren( node ) + "</div>";
|
||||
else
|
||||
if ( node.tagName == GD_NATIVE_TO_WS( L"trn" ) )
|
||||
else if( node.tagName == U"trn" )
|
||||
result += "<span class=\"dsl_trn\">" + processNodeChildren( node ) + "</span>";
|
||||
else
|
||||
if ( node.tagName == GD_NATIVE_TO_WS( L"ex" ) )
|
||||
else if( node.tagName == U"ex" )
|
||||
result += "<span class=\"dsl_ex\">" + processNodeChildren( node ) + "</span>";
|
||||
else
|
||||
if ( node.tagName == GD_NATIVE_TO_WS( L"com" ) )
|
||||
else if( node.tagName == U"com" )
|
||||
result += "<span class=\"dsl_com\">" + processNodeChildren( node ) + "</span>";
|
||||
else
|
||||
if ( node.tagName == GD_NATIVE_TO_WS( L"s" ) || node.tagName == GD_NATIVE_TO_WS( L"video" ) )
|
||||
else if( node.tagName == U"s" || node.tagName == U"video" )
|
||||
{
|
||||
string filename = Filetype::simplifyString( Utf8::encode( node.renderAsText() ), false );
|
||||
string n = resourceDir1 + FsEncoding::encode( filename );
|
||||
|
@ -1013,8 +1004,7 @@ string DslDictionary::nodeToHtml( ArticleDom::Node const & node )
|
|||
+ "\">" + processNodeChildren( node ) + "</a>";
|
||||
}
|
||||
}
|
||||
else
|
||||
if ( node.tagName == GD_NATIVE_TO_WS( L"url" ) )
|
||||
else if( node.tagName == U"url" )
|
||||
{
|
||||
string link = Html::escape( Filetype::simplifyString( Utf8::encode( node.renderAsText() ), false ) );
|
||||
if( QUrl::fromEncoded( link.c_str() ).scheme().isEmpty() )
|
||||
|
@ -1037,13 +1027,11 @@ string DslDictionary::nodeToHtml( ArticleDom::Node const & node )
|
|||
|
||||
result += "<a class=\"dsl_url\" href=\"" + link +"\">" + processNodeChildren( node ) + "</a>";
|
||||
}
|
||||
else
|
||||
if ( node.tagName == GD_NATIVE_TO_WS( L"!trs" ) )
|
||||
else if( node.tagName == U"!trs" )
|
||||
{
|
||||
result += "<span class=\"dsl_trs\">" + processNodeChildren( node ) + "</span>";
|
||||
}
|
||||
else
|
||||
if ( node.tagName == GD_NATIVE_TO_WS( L"p") )
|
||||
else if( node.tagName == U"p" )
|
||||
{
|
||||
result += "<span class=\"dsl_p\"";
|
||||
|
||||
|
@ -1090,8 +1078,7 @@ string DslDictionary::nodeToHtml( ArticleDom::Node const & node )
|
|||
|
||||
result += ">" + processNodeChildren( node ) + "</span>";
|
||||
}
|
||||
else
|
||||
if ( node.tagName == GD_NATIVE_TO_WS( L"'" ) )
|
||||
else if( node.tagName == U"'" )
|
||||
{
|
||||
// There are two ways to display the stress: by adding an accent sign or via font styles.
|
||||
// We generate two spans, one with accented data and another one without it, so the
|
||||
|
@ -1101,8 +1088,7 @@ string DslDictionary::nodeToHtml( ArticleDom::Node const & node )
|
|||
+ "<span class=\"dsl_stress_with_accent\">" + data + Utf8::encode( wstring( 1, 0x301 ) )
|
||||
+ "</span></span>";
|
||||
}
|
||||
else
|
||||
if ( node.tagName == GD_NATIVE_TO_WS( L"lang" ) )
|
||||
else if( node.tagName == U"lang" )
|
||||
{
|
||||
result += "<span class=\"dsl_lang\"";
|
||||
if( !node.tagAttrs.empty() )
|
||||
|
@ -1135,8 +1121,7 @@ string DslDictionary::nodeToHtml( ArticleDom::Node const & node )
|
|||
}
|
||||
result += ">" + processNodeChildren( node ) + "</span>";
|
||||
}
|
||||
else
|
||||
if ( node.tagName == GD_NATIVE_TO_WS( L"ref" ) )
|
||||
else if( node.tagName == U"ref" )
|
||||
{
|
||||
QUrl url;
|
||||
|
||||
|
@ -1158,8 +1143,7 @@ string DslDictionary::nodeToHtml( ArticleDom::Node const & node )
|
|||
result += string( "<a class=\"dsl_ref\" href=\"" ) + url.toEncoded().data() +"\">"
|
||||
+ processNodeChildren( node ) + "</a>";
|
||||
}
|
||||
else
|
||||
if ( node.tagName == GD_NATIVE_TO_WS( L"@" ) )
|
||||
else if( node.tagName == U"@" )
|
||||
{
|
||||
// Special case - insided card header was not parsed
|
||||
|
||||
|
@ -1174,23 +1158,19 @@ string DslDictionary::nodeToHtml( ArticleDom::Node const & node )
|
|||
result += string( "<a class=\"dsl_ref\" href=\"" ) + url.toEncoded().data() +"\">"
|
||||
+ processNodeChildren( node ) + "</a>";
|
||||
}
|
||||
else
|
||||
if ( node.tagName == GD_NATIVE_TO_WS( L"sub" ) )
|
||||
else if( node.tagName == U"sub" )
|
||||
{
|
||||
result += "<sub>" + processNodeChildren( node ) + "</sub>";
|
||||
}
|
||||
else
|
||||
if ( node.tagName == GD_NATIVE_TO_WS( L"sup" ) )
|
||||
else if( node.tagName == U"sup" )
|
||||
{
|
||||
result += "<sup>" + processNodeChildren( node ) + "</sup>";
|
||||
}
|
||||
else
|
||||
if ( node.tagName == GD_NATIVE_TO_WS( L"t" ) )
|
||||
else if( node.tagName == U"t" )
|
||||
{
|
||||
result += "<span class=\"dsl_t\">" + processNodeChildren( node ) + "</span>";
|
||||
}
|
||||
else
|
||||
if ( node.tagName == GD_NATIVE_TO_WS( L"br" ) )
|
||||
else if( node.tagName == U"br" )
|
||||
{
|
||||
result += "<br />";
|
||||
}
|
||||
|
@ -1377,7 +1357,7 @@ void DslDictionary::getArticleText( uint32_t articleAddress, QString & headword,
|
|||
{
|
||||
size_t begin = pos;
|
||||
|
||||
pos = articleData.find_first_of( GD_NATIVE_TO_WS( L"\n\r" ), begin );
|
||||
pos = articleData.find_first_of( U"\n\r" , begin );
|
||||
|
||||
if ( articleHeadword.empty() )
|
||||
{
|
||||
|
@ -1445,7 +1425,7 @@ void DslDictionary::getArticleText( uint32_t articleAddress, QString & headword,
|
|||
if( insidedCard )
|
||||
{
|
||||
// Check for next insided headword
|
||||
wstring::size_type hpos = articleData.find_first_of( GD_NATIVE_TO_WS( L"\n\r" ), pos );
|
||||
wstring::size_type hpos = articleData.find_first_of( U"\n\r" , pos );
|
||||
if ( hpos == wstring::npos )
|
||||
hpos = articleData.size();
|
||||
|
||||
|
@ -2075,37 +2055,37 @@ vector< sptr< Dictionary::Class > > makeDictionaries(
|
|||
try { // Here we intercept any errors during the read to save line at
|
||||
// which the incident happened. We need alive scanner for that.
|
||||
|
||||
if ( scanner.getDictionaryName() == GD_NATIVE_TO_WS( L"Abbrev" ) )
|
||||
continue; // For now just skip abbreviations
|
||||
if( scanner.getDictionaryName() == U"Abbrev" )
|
||||
continue; // For now just skip abbreviations
|
||||
|
||||
// Building the index
|
||||
initializing.indexingDictionary( Utf8::encode( scanner.getDictionaryName() ) );
|
||||
// Building the index
|
||||
initializing.indexingDictionary( Utf8::encode( scanner.getDictionaryName() ) );
|
||||
|
||||
gdDebug( "Dsl: Building the index for dictionary: %s\n",
|
||||
gd::toQString( scanner.getDictionaryName() ).toUtf8().data() );
|
||||
gdDebug( "Dsl: Building the index for dictionary: %s\n",
|
||||
gd::toQString( scanner.getDictionaryName() ).toUtf8().data() );
|
||||
|
||||
File::Class idx( indexFile, "wb" );
|
||||
File::Class idx( indexFile, "wb" );
|
||||
|
||||
IdxHeader idxHeader;
|
||||
IdxHeader idxHeader;
|
||||
|
||||
memset( &idxHeader, 0, sizeof( idxHeader ) );
|
||||
memset( &idxHeader, 0, sizeof( idxHeader ) );
|
||||
|
||||
// We write a dummy header first. At the end of the process the header
|
||||
// will be rewritten with the right values.
|
||||
// We write a dummy header first. At the end of the process the header
|
||||
// will be rewritten with the right values.
|
||||
|
||||
idx.write( idxHeader );
|
||||
idx.write( idxHeader );
|
||||
|
||||
string dictionaryName = Utf8::encode( scanner.getDictionaryName() );
|
||||
string dictionaryName = Utf8::encode( scanner.getDictionaryName() );
|
||||
|
||||
idx.write( (uint32_t) dictionaryName.size() );
|
||||
idx.write( dictionaryName.data(), dictionaryName.size() );
|
||||
idx.write( (uint32_t)dictionaryName.size() );
|
||||
idx.write( dictionaryName.data(), dictionaryName.size() );
|
||||
|
||||
string soundDictName = Utf8::encode( scanner.getSoundDictionaryName() );
|
||||
if( !soundDictName.empty() )
|
||||
{
|
||||
idxHeader.hasSoundDictionaryName = 1;
|
||||
idx.write( (uint32_t) soundDictName.size() );
|
||||
idx.write( soundDictName.data(), soundDictName.size() );
|
||||
string soundDictName = Utf8::encode( scanner.getSoundDictionaryName() );
|
||||
if( !soundDictName.empty() )
|
||||
{
|
||||
idxHeader.hasSoundDictionaryName = 1;
|
||||
idx.write( (uint32_t)soundDictName.size() );
|
||||
idx.write( soundDictName.data(), soundDictName.size() );
|
||||
}
|
||||
|
||||
idxHeader.dslEncoding = scanner.getEncoding();
|
||||
|
@ -2163,7 +2143,7 @@ vector< sptr< Dictionary::Class > > makeDictionaries(
|
|||
if ( eof )
|
||||
break;
|
||||
|
||||
curString.erase( 0, curString.find_first_not_of( GD_NATIVE_TO_WS( L" \t" ) ) );
|
||||
curString.erase( 0, curString.find_first_not_of( U" \t" ) );
|
||||
|
||||
if ( keys.size() )
|
||||
expandTildes( curString, keys.front() );
|
||||
|
|
|
@ -160,7 +160,7 @@ wstring ArticleDom::Node::renderAsText( bool stripTrsTag ) const
|
|||
wstring result;
|
||||
|
||||
for( list< Node >::const_iterator i = begin(); i != end(); ++i )
|
||||
if( !stripTrsTag || i->tagName != GD_NATIVE_TO_WS( L"!trs" ) )
|
||||
if( !stripTrsTag || i->tagName != U"!trs" )
|
||||
result += i->renderAsText( stripTrsTag );
|
||||
|
||||
return result;
|
||||
|
@ -169,8 +169,7 @@ wstring ArticleDom::Node::renderAsText( bool stripTrsTag ) const
|
|||
// Returns true if src == 'm' and dest is 'mX', where X is a digit
|
||||
static inline bool checkM( wstring const & dest, wstring const & src )
|
||||
{
|
||||
return ( src == GD_NATIVE_TO_WS( L"m" ) && dest.size() == 2 &&
|
||||
dest[ 0 ] == L'm' && iswdigit( dest[ 1 ] ) );
|
||||
return ( src == U"m" && dest.size() == 2 && dest[ 0 ] == L'm' && iswdigit( dest[ 1 ] ) );
|
||||
}
|
||||
|
||||
ArticleDom::ArticleDom( wstring const & str, string const & dictName,
|
||||
|
@ -252,7 +251,7 @@ ArticleDom::ArticleDom( wstring const & str, string const & dictName,
|
|||
wstring linkText = Folding::trimWhitespace( *entry );
|
||||
ArticleDom nodeDom( linkText, dictName, headword_ );
|
||||
|
||||
Node link( Node::Tag(), GD_NATIVE_TO_WS( L"@" ), wstring() );
|
||||
Node link( Node::Tag(), U"@" , wstring() );
|
||||
for( Node::iterator n = nodeDom.root.begin(); n != nodeDom.root.end(); ++n )
|
||||
link.push_back( *n );
|
||||
|
||||
|
@ -262,13 +261,13 @@ ArticleDom::ArticleDom( wstring const & str, string const & dictName,
|
|||
{
|
||||
root.push_back( link );
|
||||
if( entry != allLinkEntries.end() ) // Add line break before next entry
|
||||
root.push_back( Node( Node::Tag(), GD_NATIVE_TO_WS( L"br" ), wstring() ) );
|
||||
root.push_back( Node( Node::Tag(), U"br" , wstring() ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
stack.back()->push_back( link );
|
||||
if( entry != allLinkEntries.end() )
|
||||
stack.back()->push_back( Node( Node::Tag(), GD_NATIVE_TO_WS( L"br" ), wstring() ) );
|
||||
stack.back()->push_back( Node( Node::Tag(), U"br" , wstring() ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -349,7 +348,7 @@ ArticleDom::ArticleDom( wstring const & str, string const & dictName,
|
|||
}
|
||||
|
||||
// If the tag is [t], we update the transcriptionCount
|
||||
if ( name == GD_NATIVE_TO_WS( L"t" ) )
|
||||
if( name == U"t" )
|
||||
{
|
||||
if ( isClosing )
|
||||
{
|
||||
|
@ -361,7 +360,7 @@ ArticleDom::ArticleDom( wstring const & str, string const & dictName,
|
|||
}
|
||||
|
||||
// If the tag is [s], we update the mediaCount
|
||||
if ( name == GD_NATIVE_TO_WS( L"s" ) )
|
||||
if( name == U"s" )
|
||||
{
|
||||
if ( isClosing )
|
||||
{
|
||||
|
@ -374,14 +373,13 @@ ArticleDom::ArticleDom( wstring const & str, string const & dictName,
|
|||
|
||||
if ( !isClosing )
|
||||
{
|
||||
if ( name == GD_NATIVE_TO_WS( L"m" ) ||
|
||||
( name.size() == 2 && name[ 0 ] == L'm' && iswdigit( name[ 1 ] ) ) )
|
||||
if( name == U"m" || ( name.size() == 2 && name[ 0 ] == L'm' && iswdigit( name[ 1 ] ) ) )
|
||||
{
|
||||
// Opening an 'mX' or 'm' tag closes any previous 'm' tag
|
||||
closeTag( GD_NATIVE_TO_WS( L"m" ), stack, false );
|
||||
closeTag( U"m" , stack, false );
|
||||
}
|
||||
openTag( name, attrs, stack );
|
||||
if ( name == GD_NATIVE_TO_WS( L"br" ) )
|
||||
if( name == U"br" )
|
||||
{
|
||||
// [br] tag don't have closing tag
|
||||
closeTag( name, stack );
|
||||
|
@ -465,7 +463,7 @@ ArticleDom::ArticleDom( wstring const & str, string const & dictName,
|
|||
processUnsortedParts( linkText, true );
|
||||
ArticleDom nodeDom( linkText, dictName, headword_ );
|
||||
|
||||
Node link( Node::Tag(), GD_NATIVE_TO_WS( L"ref" ), wstring() );
|
||||
Node link( Node::Tag(), U"ref" , wstring() );
|
||||
for( Node::iterator n = nodeDom.root.begin(); n != nodeDom.root.end(); ++n )
|
||||
link.push_back( *n );
|
||||
|
||||
|
@ -640,7 +638,7 @@ void ArticleDom::openTag( wstring const & name,
|
|||
{
|
||||
list< Node > nodesToReopen;
|
||||
|
||||
if( name == GD_NATIVE_TO_WS( L"m" ) || checkM( name, GD_NATIVE_TO_WS( L"m" ) ) )
|
||||
if( name == U"m" || checkM( name, U"m" ) )
|
||||
{
|
||||
// All tags above [m] tag will be closed and reopened after
|
||||
// to avoid break this tag by closing some other tag.
|
||||
|
@ -734,7 +732,7 @@ void ArticleDom::closeTag( wstring const & name,
|
|||
nodesToReopen.push_back( Node( Node::Tag(), stack.back()->tagName,
|
||||
stack.back()->tagAttrs ) );
|
||||
|
||||
if ( stack.back()->empty() && stack.back()->tagName != GD_NATIVE_TO_WS( L"br" ) )
|
||||
if( stack.back()->empty() && stack.back()->tagName != U"br" )
|
||||
{
|
||||
// Empty nodes except [br] tag are deleted since they're no use
|
||||
|
||||
|
@ -917,19 +915,15 @@ DslScanner::DslScanner( string const & fileName ) :
|
|||
bool isLangTo = false;
|
||||
bool isSoundDict = false;
|
||||
|
||||
if ( !str.compare( 0, 5, GD_NATIVE_TO_WS( L"#NAME" ), 5 ) )
|
||||
if( !str.compare( 0, 5, U"#NAME" , 5 ) )
|
||||
isName = true;
|
||||
else
|
||||
if ( !str.compare( 0, 15, GD_NATIVE_TO_WS( L"#INDEX_LANGUAGE" ), 15 ) )
|
||||
else if( !str.compare( 0, 15, U"#INDEX_LANGUAGE" , 15 ) )
|
||||
isLangFrom = true;
|
||||
else
|
||||
if ( !str.compare( 0, 18, GD_NATIVE_TO_WS( L"#CONTENTS_LANGUAGE" ), 18 ) )
|
||||
else if( !str.compare( 0, 18, U"#CONTENTS_LANGUAGE" , 18 ) )
|
||||
isLangTo = true;
|
||||
else
|
||||
if ( !str.compare( 0, 17, GD_NATIVE_TO_WS( L"#SOUND_DICTIONARY" ), 17 ) )
|
||||
else if( !str.compare( 0, 17, U"#SOUND_DICTIONARY" , 17 ) )
|
||||
isSoundDict = true;
|
||||
else
|
||||
if ( str.compare( 0, 17, GD_NATIVE_TO_WS( L"#SOURCE_CODE_PAGE" ), 17 ) )
|
||||
else if( str.compare( 0, 17, U"#SOURCE_CODE_PAGE" , 17 ) )
|
||||
continue;
|
||||
|
||||
// Locate the argument
|
||||
|
@ -962,14 +956,11 @@ DslScanner::DslScanner( string const & fileName ) :
|
|||
// We don't need that!
|
||||
GD_FDPRINTF( stderr, "Warning: encoding was specified in a Unicode file, ignoring.\n" );
|
||||
}
|
||||
else
|
||||
if ( !wcscasecmp( arg.c_str(), GD_NATIVE_TO_WS( L"Latin" ) ) )
|
||||
else if( !arg.compare( U"Latin" ) )
|
||||
encoding = Utf8::Windows1252;
|
||||
else
|
||||
if ( !wcscasecmp( arg.c_str(), GD_NATIVE_TO_WS( L"Cyrillic" ) ) )
|
||||
else if( !arg.compare( U"Cyrillic" ) )
|
||||
encoding = Utf8::Windows1251;
|
||||
else
|
||||
if ( !wcscasecmp( arg.c_str(), GD_NATIVE_TO_WS( L"EasternEuropean" ) ) )
|
||||
else if( !arg.compare( U"EasternEuropean" ) )
|
||||
encoding = Utf8::Windows1250;
|
||||
else
|
||||
{
|
||||
|
@ -1041,7 +1032,7 @@ bool DslScanner::readNextLine( wstring & out, size_t & offset, bool only_head_wo
|
|||
#ifdef __WIN32
|
||||
out=line.toStdU32String();
|
||||
#else
|
||||
out=line.toStdWString();
|
||||
out=line.toStdU32String();
|
||||
#endif
|
||||
return true;
|
||||
|
||||
|
@ -1256,8 +1247,8 @@ void expandOptionalParts( wstring & str, list< wstring > * result,
|
|||
}
|
||||
}
|
||||
|
||||
static const wstring openBraces( GD_NATIVE_TO_WS( L"{{" ) );
|
||||
static const wstring closeBraces( GD_NATIVE_TO_WS( L"}}" ) );
|
||||
static const wstring openBraces( U"{{" );
|
||||
static const wstring closeBraces( U"}}" );
|
||||
|
||||
void stripComments( wstring & str, bool & nextLine )
|
||||
{
|
||||
|
@ -1356,11 +1347,11 @@ namespace
|
|||
|
||||
quint32 dslLanguageToId( wstring const & name )
|
||||
{
|
||||
static wstring newSp( GD_NATIVE_TO_WS( L"newspelling" ) );
|
||||
static wstring st( GD_NATIVE_TO_WS( L"standard" ) );
|
||||
static wstring ms( GD_NATIVE_TO_WS( L"modernsort" ) );
|
||||
static wstring ts( GD_NATIVE_TO_WS( L"traditionalsort" ) );
|
||||
static wstring prc( GD_NATIVE_TO_WS( L"prc" ) );
|
||||
static wstring newSp( U"newspelling" );
|
||||
static wstring st( U"standard" );
|
||||
static wstring ms( U"modernsort" );
|
||||
static wstring ts( U"traditionalsort" );
|
||||
static wstring prc( U"prc" );
|
||||
|
||||
// Any of those endings are to be removed
|
||||
|
||||
|
|
16
gls.cc
16
gls.cc
|
@ -179,13 +179,13 @@ GlsScanner::GlsScanner( string const & fileName ) :
|
|||
|
||||
wstring str;
|
||||
wstring *currentField = 0;
|
||||
wstring mark = GD_NATIVE_TO_WS( L"###" );
|
||||
wstring titleMark = GD_NATIVE_TO_WS( L"### Glossary title:" );
|
||||
wstring authorMark = GD_NATIVE_TO_WS( L"### Author:" );
|
||||
wstring descriptionMark = GD_NATIVE_TO_WS( L"### Description:" );
|
||||
wstring langFromMark = GD_NATIVE_TO_WS( L"### Source language:" );
|
||||
wstring langToMark = GD_NATIVE_TO_WS( L"### Target language:" );
|
||||
wstring endOfHeaderMark = GD_NATIVE_TO_WS( L"### Glossary section:" );
|
||||
wstring mark = U"###" ;
|
||||
wstring titleMark = U"### Glossary title:" ;
|
||||
wstring authorMark = U"### Author:" ;
|
||||
wstring descriptionMark = U"### Description:" ;
|
||||
wstring langFromMark = U"### Source language:" ;
|
||||
wstring langToMark = U"### Target language:" ;
|
||||
wstring endOfHeaderMark = U"### Glossary section:" ;
|
||||
size_t offset;
|
||||
|
||||
for( ; ; )
|
||||
|
@ -287,7 +287,7 @@ bool GlsScanner::readNextLine( wstring & out, size_t & offset )
|
|||
#ifdef __WIN32
|
||||
out = line.toStdU32String();
|
||||
#else
|
||||
out = line.toStdWString();
|
||||
out = line.toStdU32String();
|
||||
#endif
|
||||
return true;
|
||||
|
||||
|
|
|
@ -413,7 +413,6 @@ SOURCES += folding.cc \
|
|||
hunspell.cc \
|
||||
dictdfiles.cc \
|
||||
audiolink.cc \
|
||||
wstring.cc \
|
||||
wstring_qt.cc \
|
||||
processwrapper.cc \
|
||||
hotkeywrapper.cc \
|
||||
|
|
19
wstring.cc
19
wstring.cc
|
@ -1,19 +0,0 @@
|
|||
#ifdef __WIN32
|
||||
|
||||
#include "wstring.hh"
|
||||
#include "iconv.hh"
|
||||
#include <wchar.h>
|
||||
#include <QString>
|
||||
|
||||
namespace gd
|
||||
{
|
||||
wstring __nativeToWs( wchar_t const * str )
|
||||
{
|
||||
QString qStr=QString::fromWCharArray(str);
|
||||
return qStr.toStdU32String();
|
||||
//return Iconv::toWstring( "WCHAR_T", str, wcslen( str ) * sizeof( wchar_t ) );
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
15
wstring.hh
15
wstring.hh
|
@ -40,23 +40,14 @@
|
|||
/// introduce our own gd::wstring and gd::wchar types here. On all systems but
|
||||
/// Windows, they are equivalent to std::wstring and wchar_t. On Windows, they
|
||||
/// are basic_string< unsigned int > and unsigned int.
|
||||
///
|
||||
///
|
||||
/// Now we have a better built-in type as char32_t and std::u32string
|
||||
|
||||
namespace gd
|
||||
{
|
||||
|
||||
#ifdef __WIN32
|
||||
typedef char32_t wchar;
|
||||
typedef std::u32string wstring;
|
||||
// GD_NATIVE_TO_WS is used to convert L"" strings to a const pointer to
|
||||
// wchar.
|
||||
wstring __nativeToWs( wchar_t const * );
|
||||
#define GD_NATIVE_TO_WS( str ) ( gd::__nativeToWs( ( str ) ).c_str() )
|
||||
|
||||
#else
|
||||
typedef wchar_t wchar;
|
||||
typedef std::basic_string<wchar> wstring;
|
||||
#define GD_NATIVE_TO_WS( str ) ( str )
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -3,15 +3,9 @@
|
|||
|
||||
namespace gd
|
||||
{
|
||||
|
||||
|
||||
QString toQString( wstring const & in )
|
||||
{
|
||||
#ifdef __WIN32
|
||||
return QString::fromUcs4( in.c_str() );
|
||||
#else
|
||||
return QString::fromStdWString(in);
|
||||
#endif
|
||||
return QString::fromStdU32String( in );
|
||||
}
|
||||
|
||||
wstring toWString( QString const & in )
|
||||
|
|
Loading…
Reference in a new issue