For ROs, only replace spaces with hard spaces if the character before or after is number

This commit is contained in:
John Jenko 2016-06-07 19:29:51 +00:00
parent 351352b76f
commit 6a226b0480

View File

@ -603,16 +603,31 @@ namespace VEPROMS.CSLA.Library
while (spindx >= 0) while (spindx >= 0)
{ {
if (!EndsRtfCommand(newvalue, spindx, lstindx)) if (!EndsRtfCommand(newvalue, spindx, lstindx))
{
if (!SpaceBetweenLetters(newvalue, spindx)) // only replace a space with a hard space if the character before or after is a number B2016-144
{ {
newvalue = newvalue.Remove(spindx, 1); newvalue = newvalue.Remove(spindx, 1);
newvalue = newvalue.Insert(spindx, @"\u160?"); newvalue = newvalue.Insert(spindx, @"\u160?");
} }
}
lstindx = spindx; lstindx = spindx;
spindx = (spindx + 1 >= newvalue.Length)?spindx = -1: newvalue.IndexOf(" ", spindx+1); spindx = (spindx + 1 >= newvalue.Length)?spindx = -1: newvalue.IndexOf(" ", spindx+1);
} }
return newvalue; return newvalue;
} }
private bool SpaceBetweenLetters(string newvalue, int spindx)
{
if (spindx > 0 && spindx < newvalue.Length)
{
char cb = newvalue[spindx - 1];
char ca = newvalue[spindx + 1];
if (char.IsLetter(cb) && char.IsLetter(ca))
return true;
}
return false;
}
private bool EndsRtfCommand(string str, int spindx, int previndx) private bool EndsRtfCommand(string str, int spindx, int previndx)
{ {
// get text from last space to current, or from beginning of string to current: // get text from last space to current, or from beginning of string to current: