Beispiel #1
0
		/// <summary>
		/// Adds/"deletes" a given puaCharacter to the given TextWriter
		/// Will write a DerivedBidiClass.txt style line.
		/// </summary>
		/// <param name="puaCharacter">The character to add or delete</param>
		/// <param name="?"></param>
		public void AddUCDLine(TextWriter writer, UCDCharacter ucdCharacter, bool add)
		{
			if(add)
				writer.WriteLine(ucdCharacter.ToString()+" " + m_comment);
			// Uncomment this line to replace lines with a comment indicating that the line was removed.
			//			else
			//				writer.WriteLine("# DELETED LINE: {0}",puaCharacter.ToBidiString());
		}
Beispiel #2
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Compares two UCDCharacters.
		/// If the two are in the same "region" sorted as though they are identical, they will "match".
		/// For most files this will just be as simple "equals" comparing the strings.
		/// However, for the DerivedNormalizationProps.txt file,
		/// both NFC_NO and NFC_MAYBE are the in the same region.
		/// </summary>
		/// <param name="ucd">The ucd.</param>
		/// <returns>
		/// True if the properties are in the same "region" sorted as though they are identical in a file.
		///		</returns>
		/// ------------------------------------------------------------------------------------
		public bool SameRegion(UCDCharacter ucd)
		{
			return SameRegion(ucd.Property);
		}
Beispiel #3
0
		/// <summary>
		/// Read to the end of a given section of matching bidi class values.
		/// Passes everything read through to the writer.
		/// If this finds a section count comment, it will replace it with the current count.
		/// </summary>
		/// <param name="reader">The reader to read through.</param>
		/// <param name="lastBidiClass">The section we need to reed to the end of.</param>
		/// <param name="currentCount">The count of characters found before reading to the end of the section.</param>
		/// <param name="ucdCharacter">UCD Character used to know what kind of UCD file we are parsing.
		///		The actual contencts of the UCD Character are ignored.</param>
		/// <returns>The first line of the next section.</returns>
		private string ReadToEndOfSection(TextReader reader, TextWriter writer, string lastProperty, int currentCount, UCDCharacter ucdCharacter)
		{
			string line;
			string currentProperty;
			while((line = reader.ReadLine()) != null)
			{
				// if there is a bidi class value to read
				if(HasBidiData(line))
				{
					// increments the current count of codepoints found so far.
					IncrementCount(ref currentCount,line);

					// read the bidi value from the line
					currentProperty = GetProperty(line);

					// if it isn't in the current section we are done with section.
					if (!ucdCharacter.SameRegion(currentProperty,lastProperty))
						break;
				}
					// if its a comment, find the total count comment and replace it with the current count.
				else if(line.ToLowerInvariant().IndexOf("total code points")!=-1)
				{
					line = "# Total code points: " + currentCount;
					currentCount = 0;
				}
				// Write through all lines except the first line of the next section
				writer.WriteLine(line);
			}

			// Return the last line that we read
			// This is the first line of the next section, so someone will probably want to parse it.
			return line;
		}