private static void AddToLists(string line, IPuaCharacter puaDefinition,
List<IUcdCharacter> addToBidi, List<IUcdCharacter> removeFromBidi, List<IUcdCharacter> addToNorm,
List<IUcdCharacter> removeFromNorm)
{
#if DEBUGGING_SOMETHING
int temp = line.IndexOf("F16F"); // junk for a debugging breakpoint...
temp++;
#endif
// If the bidi type doesn't match add it to the lists to replace
var bidi = GetField(line, kiBidi + 1);
if (!puaDefinition.Bidi.Equals(bidi))
{
var factory = new BidiCharacterFactory();
removeFromBidi.Add(new BidiCharacter(line));
addToBidi.Add(factory.Create(puaDefinition));
}
// If the new character doesn't match the decomposition, add it to the lists
string decomposition = GetField(line, 5);
string puaRawDecomp = puaDefinition.Data[5 - 1];
if (decomposition != puaRawDecomp)
{
var factory = new NormalizationCharacterFactory();
// Perform a quick attempt to remove basic decompositions
// TODO: Extend this to actually remove more complicated entries?
// Currently this will remove anything that we have added.
if (decomposition.Trim() != string.Empty)
{
// If there is a '>' character in the decomposition field
// then it is a compatability decomposition
if (decomposition.IndexOf(">") != -1)
removeFromNorm.Add(factory.Create(line, "NFKD_QC; N"));
removeFromNorm.Add(factory.Create(line, "NFD_QC; N"));
}
// Add the normalization to the lists, if necessary.
if (puaDefinition.Decomposition != string.Empty)
{
// Add a canonical decomposition if necessary
if (puaDefinition.DecompositionType == string.Empty)
addToNorm.Add(factory.Create(puaDefinition, "NFD_QC; N"));
// Add a compatability decomposition always
// (Apparently canonical decompositions are compatability decompositions,
// but not vise-versa
addToNorm.Add(factory.Create(puaDefinition, "NFKD_QC; N"));
}
}
}