public void SetUp() { m_comparer = new UCDComparer(); m_bidi = new BidiCharacter("0669", "ARABIC-INDIC DIGIT NINE;Nd;0;AN;;9;9;9;N;;;;;"); m_pua = new PUACharacter("0669", "ARABIC-INDIC DIGIT NINE;Nd;0;AN;;9;9;9;N;;;;;"); }
/// <summary> /// Installs the PUA characters (PUADefinitions) from the given xml file /// We do this by: /// 1.Maps the XML file to our LanguageDefinition class /// 2.Sorts the PUA characters /// 3.Opens UnicodeData.txt for reading and writing /// 4.Inserts the PUA characters via their codepoints /// 5. Update the DerivedBidiClass.txt file so that the bidi values match /// 6. Run the "genprops" command to write the actual files /// </summary> /// <param name="m_ldData">Our XML file containing our PUA Defintions</param> public void InstallPUACharacters(string ldFilename) { // 0. Intro: Prepare files // 0.1: File names string unicodeDataFilename = Generic.GetIcuDir() + @"data\unidata\UnicodeData.txt"; string derivedBidiClassFilename = Generic.GetIcuDir() + @"data\unidata\DerivedBidiClass.txt"; string derivedNormalizationPropsFilename = Generic.GetIcuDir() + @"data\unidata\DerivedNormalizationProps.txt"; // 0.2: Create a one-time backup that will not be over written if the file exists Generic.BackupOrig(unicodeDataFilename); Generic.BackupOrig(derivedBidiClassFilename); Generic.BackupOrig(derivedNormalizationPropsFilename); // 0.3: Create a stack of files to restore if we encounter and error // This allows us to work with the original files // If we are successful we call this.RemoveBackupFiles() to clean up // If we are not we call this.RestoreFiles() to restore the original files // and delete the backups string unicodeDataBackup = Generic.CreateBackupFile(unicodeDataFilename); string derivedBidiClassBackup = Generic.CreateBackupFile(derivedBidiClassFilename); string derivedNormalizationPropsBackup = Generic.CreateBackupFile(derivedNormalizationPropsFilename); this.AddUndoFileFrame(unicodeDataFilename,unicodeDataBackup); this.AddUndoFileFrame(derivedBidiClassFilename,derivedBidiClassBackup); this.AddUndoFileFrame(derivedNormalizationPropsFilename, derivedNormalizationPropsBackup); //Initialize and populate the parser if necessary // 1. Maps our XML file to the LanguageDefinition class ParseLanguageDataFile(ldFilename); // There are no characters to install, we are done; if(m_ldData.PuaDefinitions == null || m_ldData.PuaDefinitions.Length == 0) { LogFile.AddLine("There are no PUA characters to install"); return; } // (Step 1 has been moved before the "intro") // 2. Sort the PUA characters System.Array.Sort(m_ldData.PuaDefinitions); // 3. Open the file for reading and writing // 4. Insert the PUA via their codepoints ArrayList addToBidi; ArrayList removeFromBidi; ArrayList addToNorm; ArrayList removeFromNorm; InsertCharacters(m_ldData.PuaDefinitions, out addToBidi, out removeFromBidi, out addToNorm, out removeFromNorm); // 5. Update the DerivedBidiClass.txt file so that the bidi values match UCDComparer comparer = new UCDComparer(); addToBidi.Sort(comparer); removeFromBidi.Sort(comparer); addToNorm.Sort(comparer); removeFromNorm.Sort(comparer); UpdateUCDFile(addToBidi,removeFromBidi); UpdateUCDFile(addToNorm,removeFromNorm); // 6. Run the "genprops","gennames","gennorm" commands to write the actual files RunICUPUATools(); }