Exemplo n.º 1
0
        private void OnOptionVariableTop(object sender, ActionEventArgs args)
        {
            IcuDataObject attr         = IcuDataObject.CreateAttribute("variableTop");
            IcuDataObject previousNode = _currentNodes[_currentNodes.Count - 1];

            if (previousNode.Name == "x")
            {
                throw new ApplicationException("[variable top] cannot follow an extended node (prefix, expasion, or both).");
            }
            if (previousNode.InnerText.Length == 0)
            {
                throw new ApplicationException("[variable top] cannot follow an indirect position");
            }
            string unescapedValue = previousNode.InnerText;
            string escapedValue   = string.Empty;

            for (int i = 0; i < unescapedValue.Length; i++)
            {
                escapedValue += String.Format("u{0:X}", Char.ConvertToUtf32(unescapedValue, i));
                // if we had a surogate, that means that two "char"s were encoding one code point,
                // so skip the next "char" as it was already handled in this iteration
                if (Char.IsSurrogate(unescapedValue, i))
                {
                    i++;
                }
            }
            attr.Value = escapedValue;
            AddSettingsAttribute(attr);
        }
Exemplo n.º 2
0
        private void OnOptionHiraganaQ(object sender, ActionEventArgs args)
        {
            IcuDataObject attr = IcuDataObject.CreateAttribute("hiraganaQuaternary");

            attr.Value = args.Value.EndsWith("on") ? "on" : "off";
            AddSettingsAttribute(attr);
        }
Exemplo n.º 3
0
        private void OnOptionStrength(object sender, ActionEventArgs args)
        {
            IcuDataObject attr = IcuDataObject.CreateAttribute("strength");

            switch (args.Value[args.Value.Length - 1])
            {
            case '1':
                attr.Value = "primary";
                break;

            case '2':
                attr.Value = "secondary";
                break;

            case '3':
                attr.Value = "tertiary";
                break;

            case '4':
                attr.Value = "quaternary";
                break;

            case '5':
            case 'I':
            case 'i':
                attr.Value = "identical";
                break;

            default:
                Debug.Assert(false, "Unhandled strength option.");
                break;
            }
            AddSettingsAttribute(attr);
        }
Exemplo n.º 4
0
        private void OnOptionNormal(object sender, ActionEventArgs args)
        {
            Regex regex = new Regex("(\\S+)\\s+(\\S+)");
            Match match = regex.Match(args.Value);

            Debug.Assert(match.Success);
            IcuDataObject attr = IcuDataObject.CreateAttribute(match.Groups[1].Value, match.Groups[2].Value);

            AddSettingsAttribute(attr);
        }
Exemplo n.º 5
0
        private void OnOptionBackwards(object sender, ActionEventArgs args)
        {
            IcuDataObject attr = IcuDataObject.CreateAttribute("backwards");

            switch (args.Value[args.Value.Length - 1])
            {
            case '1':
                attr.Value = "off";
                break;

            case '2':
                attr.Value = "on";
                break;

            default:
                Debug.Assert(false, "Unhandled backwards option.");
                break;
            }
            AddSettingsAttribute(attr);
        }
Exemplo n.º 6
0
        private void AddAttributeForReset(string name, string value)
        {
            IcuDataObject attr = IcuDataObject.CreateAttribute(name, value);

            _attributesForReset.Enqueue(attr);
        }