Quote:
Originally Posted by KevinH
I think you can easily change that to the named entity if you want but I will have to look closer to be sure.
|
You can.
Quote:
Originally Posted by KevinH
My idea would be to create a Prefs dialog with the 10 or so most common named entities which the user can enable or disable and expand this routine to replace the selected QChar values with those desired named entities (ie it would only preserve those entities as named entities).
A similar approach could be used for numeric entities as well.
The key is that this routine is invoked a lot and so must run quickly so supporting all possible entities would be hard.
I am thinking of a hashtable (dictionary) with char lookup value and replacement value or a simple range check and then subtraction of base value to get an offset to its replacement value.
That should make things fast even for 10 to 20 named entities.
What do you think? Again, I have just eyeballed this briefly, so I could be all wet here.
|
Having a preference dialog doesn't sound bad. The user can specify which characters they want converted and they can specify if they want named or numeric. There are a few ways this dialog could look. I'm not going to weigh in on that part.
You'd probably want to keep the list charters to entities in a hastable and also keep a list of the entities to match. Something like:
Code:
QString CleanSource::CharToEntity(const QString &source)
{
QString new_source = source;
Q_FOREACH (QChar c, m_chars) {
new_source.replace(c, m_charToEntity->value(c, c));
}
return new_source;
}