From e11530f0c07eb6565a717d9aa9c6b5a35d04c8c4 Mon Sep 17 00:00:00 2001 From: donho Date: Sun, 14 Dec 2008 22:30:57 +0000 Subject: [PATCH] [BUG_FIXED]Fix the bug that Unicode path file opened in the previous session doesn't be restored. git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository@368 f5eea248-9336-0410-98b8-ebc06183d4e3 --- PowerEditor/src/TinyXml/tinyxml.cpp | 2 +- PowerEditor/src/TinyXml/tinyxmlparser.cpp | 32 ++++++----------------- 2 files changed, 9 insertions(+), 25 deletions(-) diff --git a/PowerEditor/src/TinyXml/tinyxml.cpp b/PowerEditor/src/TinyXml/tinyxml.cpp index 58ce6d2ce..7e18d3da3 100644 --- a/PowerEditor/src/TinyXml/tinyxml.cpp +++ b/PowerEditor/src/TinyXml/tinyxml.cpp @@ -92,7 +92,7 @@ void TiXmlBase::PutString( const TIXML_STRING& str, TIXML_STRING* outString ) // Easy pass at non-alpha/numeric/symbol // 127 is the delete key. Below 32 is symbolic. TCHAR buf[ 32 ]; - wsprintf( buf, TEXT("&#x%02X;"), (unsigned) ( c & 0xff ) ); + wsprintf( buf, TEXT("&#x%04X;"), (unsigned) ( c & 0xffff ) ); outString->append( buf, lstrlen( buf ) ); ++i; } diff --git a/PowerEditor/src/TinyXml/tinyxmlparser.cpp b/PowerEditor/src/TinyXml/tinyxmlparser.cpp index 8aa5436a2..d41f94e93 100644 --- a/PowerEditor/src/TinyXml/tinyxmlparser.cpp +++ b/PowerEditor/src/TinyXml/tinyxmlparser.cpp @@ -223,36 +223,20 @@ const TCHAR* TiXmlBase::ReadName( const TCHAR* p, TIXML_STRING * name ) const TCHAR* TiXmlBase::GetEntity( const TCHAR* p, TCHAR* value ) { // Presume an entity, and pull it out. - TIXML_STRING ent; int i; // Handle the &#x entities. - if ( generic_strncmp( TEXT("&#x"), p, 3 ) == 0 - && *(p+3) - && *(p+4) - && ( *(p+4) == ';' || *(p+5) == ';' ) - ) + if (generic_strncmp( TEXT("&#x"), p, 3 ) == 0) { - *value = 0; - - if ( *(p+4) == ';' ) + const TCHAR* end = generic_strchr(p+3, TEXT(';')); + if (end && end - p <= 3 + 4) { - // Short, one value entity. - if ( isalpha( *(p+3) ) ) *value += ( tolower( *(p+3) ) - 'a' + 10 ); - else *value += ( *(p+3) - '0' ); - - return p+5; - } - else + int val; + if (generic_sscanf(p+3, TEXT("%x"), &val) == 1) { - // two value entity - if ( isalpha( *(p+3) ) ) *value += ( tolower( *(p+3) ) - 'a' + 10 ) * 16; - else *value += ( *(p+3) - '0' ) * 16; - - if ( isalpha( *(p+4) ) ) *value += ( tolower( *(p+4) ) - 'a' + 10 ); - else *value += ( *(p+4) - '0' ); - - return p+6; + *value = val; + return end + 1; + } } }