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

@ -604,8 +604,11 @@ namespace VEPROMS.CSLA.Library
{
if (!EndsRtfCommand(newvalue, spindx, lstindx))
{
newvalue = newvalue.Remove(spindx, 1);
newvalue = newvalue.Insert(spindx, @"\u160?");
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.Insert(spindx, @"\u160?");
}
}
lstindx = spindx;
spindx = (spindx + 1 >= newvalue.Length)?spindx = -1: newvalue.IndexOf(" ", spindx+1);
@ -613,6 +616,18 @@ namespace VEPROMS.CSLA.Library
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)
{
// get text from last space to current, or from beginning of string to current: