Example #1
0
		internal PUACharacter FindCachedIcuEntry(string sCode)
		{
			int code;
			if (Int32.TryParse(sCode, NumberStyles.HexNumber, CultureInfo.InvariantCulture, out code))
			{
				PUACharacter charSpec;
				if (m_dictCustomChars.TryGetValue(code, out charSpec))
					return charSpec;
				if (m_dictModifiedChars.TryGetValue(code, out charSpec))
					return charSpec;
				charSpec = new PUACharacter(code);
				if (charSpec.RefreshFromIcu(true))
					return charSpec; // known character we have no overrides for
			}
			return null;
		}
Example #2
0
			internal PuaListItem(PUACharacter spec)
				: base(GetListViewSubItemsArray(spec))
			{
				Tag = spec;
				Int32.TryParse(spec.CodePoint, NumberStyles.HexNumber, CultureInfo.InvariantCulture, out m_code);
			}
Example #3
0
		private void ReadDataFromUnicodeFiles()
		{
			var icuDir = Icu.DefaultDirectory;
			if (string.IsNullOrEmpty(icuDir))
				throw new Exception("An error occurred: ICU directory not found. Registry value for ICU not set?");
			var unicodeDataFilename = Path.Combine(icuDir, "UnicodeDataOverrides.txt");
			if (!File.Exists(unicodeDataFilename))
				return;
			using (var reader = File.OpenText(unicodeDataFilename))
			{
				while (reader.Peek() >= 0)
				{
					var sLine = ReadLineAndRemoveComment(reader);
					if (String.IsNullOrEmpty(sLine))
						continue;
					var idx = sLine.IndexOf(';');
					if (idx <= 0)
						continue;
					var sCode = sLine.Substring(0, idx).Trim();
					if (String.IsNullOrEmpty(sCode))
						continue;
					var sProps = sLine.Substring(idx + 1).Trim();
					if (sProps.StartsWith("<") && sProps.Contains("Private Use"))
						continue;
					int code;
					int codeMax;
					if (!ParseCodeField(sCode, out code, out codeMax))
						continue;
					if (code != codeMax)
						continue;
					string[] dataProperties = sProps.Split(';');
					if (dataProperties.Length == PUACharacter.ExectedPropCount + 1)
					{
						// One extra is OK...I think it comes from a comment in the SIL PUA properties.
						// But the PUACharacter contsructor doesn't like it, so strip it off.
						int ich = sProps.LastIndexOf(';');
						sProps = sProps.Substring(0, ich);
					}
					var charSpec = new PUACharacter(sCode, sProps);
					m_dictModifiedChars.Add(code, charSpec);
				}
			}
		}
Example #4
0
		private void ReadCustomCharData(string customCharsFile)
		{
			var xd = XDocument.Load(customCharsFile, 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);
				}
			}
		}
Example #5
0
		private static string[] GetListViewSubItemsArray(PUACharacter cs)
		{
			var rgs = new string[10];
			rgs[0] = cs.CodePoint;
			rgs[1] = cs.Name;
			rgs[2] = cs.GeneralCategory.ToString();
			rgs[3] = cs.CanonicalCombiningClass.ToString();
			rgs[4] = cs.BidiClass.ToString();
			rgs[5] = cs.Decomposition;
			rgs[6] = cs.BidiMirrored.ToString();
			rgs[7] = cs.Upper;
			rgs[8] = cs.Lower;
			rgs[9] = cs.Title;
			return rgs;
		}
 internal PuaListItem(PUACharacter spec)
     : base(GetListViewSubItemsArray(spec))
 {
     Tag = spec;
     Int32.TryParse(spec.CodePoint, NumberStyles.HexNumber, CultureInfo.InvariantCulture, out m_code);
 }
        private void ReadDataFromUnicodeFiles()
        {
            var icuDir = Icu.DefaultDirectory;

            if (string.IsNullOrEmpty(icuDir))
            {
                throw new Exception("An error occurred: ICU directory not found. Registry value for ICU not set?");
            }
            var unicodeDataFilename = Path.Combine(icuDir, "UnicodeDataOverrides.txt");

            if (!File.Exists(unicodeDataFilename))
            {
                return;
            }
            using (var reader = File.OpenText(unicodeDataFilename))
            {
                while (reader.Peek() >= 0)
                {
                    var sLine = ReadLineAndRemoveComment(reader);
                    if (String.IsNullOrEmpty(sLine))
                    {
                        continue;
                    }
                    var idx = sLine.IndexOf(';');
                    if (idx <= 0)
                    {
                        continue;
                    }
                    var sCode = sLine.Substring(0, idx).Trim();
                    if (String.IsNullOrEmpty(sCode))
                    {
                        continue;
                    }
                    var sProps = sLine.Substring(idx + 1).Trim();
                    if (sProps.StartsWith("<") && sProps.Contains("Private Use"))
                    {
                        continue;
                    }
                    int code;
                    int codeMax;
                    if (!ParseCodeField(sCode, out code, out codeMax))
                    {
                        continue;
                    }
                    if (code != codeMax)
                    {
                        continue;
                    }
                    string[] dataProperties = sProps.Split(';');
                    if (dataProperties.Length == PUACharacter.ExectedPropCount + 1)
                    {
                        // One extra is OK...I think it comes from a comment in the SIL PUA properties.
                        // But the PUACharacter contsructor doesn't like it, so strip it off.
                        int ich = sProps.LastIndexOf(';');
                        sProps = sProps.Substring(0, ich);
                    }
                    var charSpec = new PUACharacter(sCode, sProps);
                    m_dictModifiedChars.Add(code, charSpec);
                }
            }
        }
Example #8
0
 public void PuaCharacterTextConstructor()
 {
     PUACharacter puaCharacter = new PUACharacter("0669", "ARABIC-INDIC DIGIT NINE;Nd;0;AN;;9;9;9;N;;;;;");
 }
Example #9
0
 public string CodepointAsString(string codepoint)
 {
     return(PUACharacter.CodepointAsString(codepoint));
 }