Author: gs
Date: Thu Aug 13 11:51:16 2009
New Revision: 58333
URL: http://svn.opensuse.org/viewcvs/yast?rev=58333&view=rev
Log:
Replace y; elements in richtext by their ascii
character equivalents
Modified:
branches/SuSE-SLE-10-SP3-Branch/ncurses/src/NCRichText.cc
Modified: branches/SuSE-SLE-10-SP3-Branch/ncurses/src/NCRichText.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-SLE-10-SP3-Branch/ncurses/src/NCRichText.cc?rev=58333&r1=58332&r2=58333&view=diff
==============================================================================
--- branches/SuSE-SLE-10-SP3-Branch/ncurses/src/NCRichText.cc (original)
+++ branches/SuSE-SLE-10-SP3-Branch/ncurses/src/NCRichText.cc Thu Aug 13 11:51:16 2009
@@ -21,6 +21,7 @@
#include "NCRichText.h"
#include "YNCursesUI.h"
#include "stringutil.h"
+#include <sstream>
#if 0
#undef DBG_CLASS
@@ -48,28 +49,52 @@
//
const wstring NCRichText::entityLookup( const std::wstring & val_r )
{
+ //strip leading '#', if any
+ wstring s = val_r.substr(val_r.find(L"#",0) + 1 );
+ wchar_t *endptr;
+ wstring ascii = L"";
+ //and try to convert to int
+ long int c = std::wcstol(s.c_str(), &endptr, 0);
+
+ //conversion succeeded
+ if (s.c_str() != endptr) {
+ // convert to char
+ std::wostringstream ws;
+ ws << char(c);
+ ascii = ws.str();
+ }
+
+ #define REP(l,r) _charentity[l] = r
if ( _charentity.empty() ) {
// initialize replacement for character entities. A value of NULL
// means do not replace.
wstring product;
NCstring::RecodeToWchar( YNCursesUI::ui()->productName(), "UTF-8", &product);
-#define REP(l,r) _charentity[l] = r
- REP(L"amp", L"&");
- REP(L"gt", L">");
- REP(L"lt", L"<");
+ REP(L"amp", L"&");
+ REP(L"gt", L">");
+ REP(L"lt", L"<");
REP(L"nbsp", L" ");
REP(L"quot", L"\"");
REP(L"product", product);
-#undef REP
}
std::map