public void SetUp() { m_DebugProcs = new DebugProcs(); 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> /// Determines whether or not the specified codepoint is defined in ICU. If it is and /// its a custom PUA character, then make sure the language definition's PUA character /// collection is updated. Return false if the codepoint is not defined in ICU. /// </summary> /// ------------------------------------------------------------------------------------ private static bool IsCodePointDefined(int codepoint) { PUACharacter puaChar = new PUACharacter(codepoint); try { // If the definition doesn't exist in ICU or the character has no name then // it's undefined and shouldn't be allowed in the valid characters list. if (!puaChar.RefreshFromIcu(false) || puaChar.Name.Length == 0) return false; // If the ICU category is one of the "Other" categories, then it's // undefined and shouldn't be allowed in the valid characters list. string ucdrep = puaChar.GeneralCategory.UcdRepresentation; ucdrep = ucdrep.ToUpperInvariant(); // TODO: When tabs are supported, then allow them (they are in category Cc). // See TE-3004. if (ucdrep[0] == 'C' && ucdrep[1] != 'F') return false; } catch { return false; } return true; }
private void ParseCustomCharsFile(string filename) { var ci = CultureInfo.CreateSpecificCulture("en-US"); m_comment = String.Format("[SIL-Corp] {0} User Added {1}", filename, DateTime.Now.ToString("F", ci)); m_chars = new List<PUACharacter>(); var xd = XDocument.Load(filename, LoadOptions.None); foreach (var xe in xd.Descendants("CharDef")) { var xaCode = xe.Attribute("code"); if (xaCode == null || String.IsNullOrEmpty(xaCode.Value)) continue; var xaData = xe.Attribute("data"); if (xaData == null || String.IsNullOrEmpty(xaData.Value)) continue; int code; if (Int32.TryParse(xaCode.Value, NumberStyles.HexNumber, CultureInfo.InvariantCulture, out code) && !m_dictCustomChars.ContainsKey(code)) { var spec = new PUACharacter(xaCode.Value, xaData.Value); m_dictCustomChars.Add(code, spec); m_chars.Add(spec); } } }
public void UcdWithPua() { Assert.AreEqual(0, m_comparer.Compare(m_pua, m_bidi)); Assert.AreEqual(0, m_comparer.Compare(m_bidi, m_pua)); PUACharacter otherPua; otherPua = new PUACharacter("004F", "LATIN CAPITAL LETTER O;Lu;0;L;;;;;N;;;;006F;"); Assert.Greater(m_comparer.Compare(m_bidi, otherPua), 0); BidiCharacter otherBidi; otherBidi = new BidiCharacter("004F", "LATIN CAPITAL LETTER O;Lu;0;L;;;;;N;;;;006F;"); Assert.Greater(m_comparer.Compare(m_pua, otherBidi), 0); }
public void PuaWithPua() { PUACharacter otherPua = m_pua; Assert.AreEqual(0, m_comparer.Compare(m_pua, otherPua)); otherPua = new PUACharacter("0669", "ARABIC-INDIC DIGIT NINE;Nd;0;AN;;9;9;9;N;;;;;"); Assert.AreEqual(0, m_comparer.Compare(m_pua, otherPua)); otherPua = new PUACharacter("004F", "LATIN CAPITAL LETTER O;Lu;0;L;;;;;N;;;;006F;"); Assert.Greater(m_comparer.Compare(m_pua, otherPua), 0); otherPua = new PUACharacter("0668", "ARABIC-INDIC DIGIT EIGHT;Nd;0;AN;;8;8;8;N;;;;;"); Assert.Greater(m_comparer.Compare(m_pua, otherPua), 0); }
public void PuaCharacterToString() { string unicodeData = "VULGAR FRACTION ONE THIRD;No;0;ON;<fraction> 0031 2044 0033;;;1/3;N;FRACTION ONE THIRD;;;;"; PUACharacter puaChar = new PUACharacter("2153",unicodeData); Assert.AreEqual("2153;" + unicodeData, puaChar.ToString(), "Error while writing PUACharacter"); }
public void PuaCharacterTextConstructor() { PUACharacter puaCharacter = new PUACharacter("0669", "ARABIC-INDIC DIGIT NINE;Nd;0;AN;;9;9;9;N;;;;;"); }
/// <summary> /// Compares two PUACharacters to see if they are the same. /// </summary> /// <param name="puaChar">The second PUACharacter to compare with.</param> /// <returns><c>true</c> if the characters are identical.</returns> public bool Equals(PUACharacter puaChar) { return this.m_codepoint == puaChar.m_codepoint && this.m_name == puaChar.m_name && this.m_generalCategory.Equals(puaChar.m_generalCategory) && this.m_canonicalCombiningClass.Equals(puaChar.m_canonicalCombiningClass) && this.m_bidiClass.Equals(puaChar.m_bidiClass) && this.m_decompositionType.Equals(puaChar.m_decompositionType) && this.m_decomposition == puaChar.m_decomposition && this.m_numericType == puaChar.m_numericType && this.m_numericValue == puaChar.m_numericValue && this.m_bidiMirrored.Equals(puaChar.m_bidiMirrored) && this.m_unicode1Name == puaChar.m_unicode1Name && this.m_isoComment == puaChar.m_isoComment && this.m_upper == puaChar.m_upper && this.m_lower == puaChar.m_lower && this.m_title == puaChar.m_title; }