Example #1
0
 public void FindRange()
 {
     // Just a few random examples
     Assert.AreSame(UnicodeRange.BasicLatin, UnicodeRange.GetRange('c'));
     Assert.AreSame(UnicodeRange.CurrencySymbols, UnicodeRange.GetRange('\u20ac'));
     Assert.AreSame(UnicodeRange.MiscellaneousTechnical, UnicodeRange.GetRange('\u2300'));
     Assert.IsNull(UnicodeRange.GetRange('\u0750'));
 }
        public void Ctor_SuccessCase()
        {
            // Act
            var range = new UnicodeRange(0x0100, 128); // Latin Extended-A

            // Assert
            Assert.Equal(0x0100, range.FirstCodePoint);
            Assert.Equal(128, range.Length);
        }
Example #3
0
        public void UnicodeRange_ToJson_1()
        {
            UnicodeRange range = new UnicodeRange();

            Assert.AreEqual("{\'from\':\"\\u0000\",\'to\':\"\\u0000\"}", JsonUtility.SerializeShort(range));

            range = _GetRange();
            Assert.AreEqual("{\'name\':\'Lower Latin\',\'from\':\"a\",\'to\':\"z\"}", JsonUtility.SerializeShort(range));
        }
        public void FromSpan_SuccessCase()
        {
            // Act
            var range = UnicodeRange.Create('\u0180', '\u024F'); // Latin Extended-B

            // Assert
            Assert.Equal(0x0180, range.FirstCodePoint);
            Assert.Equal(208, range.Length);
        }
        public void FromSpan_SuccessCase_All()
        {
            // Act
            var range = UnicodeRange.Create('\u0000', '\uFFFF');

            // Assert
            Assert.Equal(0, range.FirstCodePoint);
            Assert.Equal(0x10000, range.Length);
        }
Example #6
0
        public void UnicodeRange_ToXml_1()
        {
            UnicodeRange range = new UnicodeRange();

            Assert.AreEqual("<range from=\"0\" to=\"0\" />", XmlUtility.SerializeShort(range));

            range = _GetRange();
            Assert.AreEqual("<range name=\"Lower Latin\" from=\"97\" to=\"122\" />", XmlUtility.SerializeShort(range));
        }
Example #7
0
        public void UnicodeRange_Serialization_1()
        {
            UnicodeRange range = new UnicodeRange();

            _TestSerialization(range);

            range = _GetRange();
            _TestSerialization(range);
        }
Example #8
0
        public void UnicodeRange_Construction_2()
        {
            string       name  = "Lower Latin";
            UnicodeRange range = new UnicodeRange(name, 'a', 'z');

            Assert.AreEqual(name, range.Name);
            Assert.AreEqual('a', range.From);
            Assert.AreEqual('z', range.To);
        }
Example #9
0
        public void UnicodeRange_Verify_1()
        {
            UnicodeRange range = new UnicodeRange();

            Assert.IsFalse(range.Verify(false));

            range = _GetRange();
            Assert.IsTrue(range.Verify(false));
        }
 public Group(UnicodeRange range, string groupName, string name, string ids, UnicodeChart chart)
 {
     UnicodeRange = new UnicodeRange(range);
     GroupName    = groupName;
     Name         = name;
     Ids          = ids;
     UnicodeChart = chart;
     SubGroups    = null;
 }
Example #11
0
        public void Ctor_SuccessCase()
        {
            // Act
            var range = new UnicodeRange(0x0100, 128); // Latin Extended-A

            // Assert
            Assert.Equal(0x0100, range.FirstCodePoint);
            Assert.Equal(128, range.Length);
        }
        public static void Range_None()
        {
            UnicodeRange range = UnicodeRanges.None;

            Assert.NotNull(range);

            // Test 1: the range should be empty
            Assert.Equal(0, range.FirstCodePoint);
            Assert.Equal(0, range.Length);
        }
Example #13
0
 public override string ToString()
 {
     if (UnicodeRange != null)
     {
         return(UnicodeRange.ToString() + " " + Typography.OpenFont.TagUtils.TagToString(ScriptTag) + ":" + Typography.OpenFont.TagUtils.TagToString(LangTag));
     }
     else
     {
         return(Typography.OpenFont.TagUtils.TagToString(ScriptTag) + ":" + Typography.OpenFont.TagUtils.TagToString(LangTag));
     }
 }
 public SlugOptions()
 {
     MaximumLength = DefaultMaximumLength;
     Separator     = DefaultSeparator;
     AllowedRanges = new List <UnicodeRange>
     {
         UnicodeRange.Create('a', 'z'),
         UnicodeRange.Create('A', 'Z'),
         UnicodeRange.Create('0', '9'),
     };
 }
Example #15
0
        private void _TestSerialization
        (
            [NotNull] UnicodeRange first
        )
        {
            byte[]       bytes  = first.SaveToMemory();
            UnicodeRange second = bytes.RestoreObjectFromMemory <UnicodeRange>();

            Assert.AreEqual(first.Name, second.Name);
            Assert.AreEqual(first.From, second.From);
            Assert.AreEqual(first.To, second.To);
        }
Example #16
0
        public void RichText_Encode_5()
        {
            UnicodeRange range = UnicodeRange.Russian;

            Assert.AreEqual(null, RichText.Encode2(null, range));
            Assert.AreEqual("", RichText.Encode2("", range));
            Assert.AreEqual("\\'09", RichText.Encode2("\t", range));
            Assert.AreEqual("Привет", RichText.Encode2("Привет", range));
            Assert.AreEqual("\\u12371?\\u12435?\\u12395?\\u12385?\\u12399?",
                            RichText.Encode2("こんにちは", range));
            Assert.AreEqual("Geld f\\'fcr Maria : erz\\'e4hlung",
                            RichText.Encode2("Geld für Maria : erzählung", range));
        }
Example #17
0
 public static bool Contains(UnicodeRangeFilterType mask, char c)
 {
     for (int i = 0; i < unicodeRanges.Length; i++)
     {
         UnicodeRange range = _unicodeRanges[i];
         if (IntBitFlags.HasFlag((int)mask, (int)range.type))
         {
             if (range.Contains(c))
             {
                 return(true);
             }
         }
     }
     return(false);
 }
Example #18
0
        public void RichText_Encode_6()
        {
            UnicodeRange range      = UnicodeRange.Russian;
            string       fontSwitch = "\\f2";

            Assert.AreEqual(null, RichText.Encode3(null, range, fontSwitch));
            Assert.AreEqual("", RichText.Encode3("", range, fontSwitch));
            Assert.AreEqual("\\'09", RichText.Encode3("\t", range, fontSwitch));
            Assert.AreEqual("Привет", RichText.Encode3("Привет", range, fontSwitch));
            Assert.AreEqual("\\u12371?\\u12435?\\u12395?\\u12385?\\u12399?",
                            RichText.Encode3("こんにちは", range, fontSwitch));
            Assert.AreEqual("Geld f{\\f2\\'fc}r Maria : erz{\\f2\\'e4}hlung",
                            RichText.Encode3("Geld für Maria : erzählung", range,
                                             fontSwitch));
        }
        public static void Range_Unicode(ushort first, ushort last, string blockName)
        {
            Assert.Equal(0x0, first & 0xF); // first char in any block should be U+nnn0
            Assert.Equal(0xF, last & 0xF);  // last char in any block should be U+nnnF
            Assert.True(first < last);      // code point ranges should be ordered

            var propInfo = typeof(UnicodeRanges).GetRuntimeProperty(blockName);

            Assert.NotNull(propInfo);

            UnicodeRange range = (UnicodeRange)propInfo.GetValue(null);

            Assert.NotNull(range);

            // Test 1: the range should span the range first..last
            Assert.Equal(first, range.FirstCodePoint);
            Assert.Equal(last, range.FirstCodePoint + range.Length - 1);
        }
Example #20
0
            static bool IsInRange(UnicodeRange range, char c)
            {
                var val = (int)c;

                return(val >= range.FirstCodePoint && val <= (range.FirstCodePoint + range.Length));
            }
 public virtual void ForbidRange(UnicodeRange range);
 private bool IsCharInRange(char ch, UnicodeRange range)
 {
     return(range.FirstCodePoint <= ch && ch < range.FirstCodePoint + range.Length);
 }
Example #23
0
 /// <summary>
 /// constructor of PropertyData stuct
 /// </summary>
 public UnicodeRangeProperty(TextUtil.UnicodeChartType type, string name, string ids, UnicodeRange range)
 {
     Type = type;
     Name = name;
     CultureIDs = ids;
     Range = new UnicodeRange(range.StartOfUnicodeRange, range.EndOfUnicodeRange);
 }
 public virtual void AllowRange(UnicodeRange range);
 public HtmlEncoder(UnicodeRange allowedRange) : this(new TextEncoderSettings(allowedRange))
 { }
Example #26
0
        public void UnicodeRange_ToString_1()
        {
            UnicodeRange range = _GetRange();

            Assert.AreEqual("Lower Latin: 97-122", range.ToString());
        }
Example #27
0
        public void Should_Parse_Segments()
        {
            var range = UnicodeRange.Parse("U+0, U+1, U+2, U+3");

            Assert.Equal(new[] { 0, 1, 2, 3 }, range.Segments.Select(x => x.Start));
        }
 public static bool ContainsRange(FontVariant v, UnicodeRange range)
 {
     return(v.UnicodeRanges.Any(r => r.First <= range.End && range.Start <= r.Last));
 }
 public void FromSpan_FailureCase()
 {
     AssertExtensions.Throws <ArgumentOutOfRangeException>("lastCharacter", () => UnicodeRange.Create('\u0020', '\u0010'));
 }
Example #30
0
 private static bool CharIsInUnicodeRange(char ch, UnicodeRange range)
 {
     return(ch >= range.FirstCodePoint && ch < range.FirstCodePoint + range.Length);
 }
 public JavaScriptStringEncoder(UnicodeRange allowedRange) : this(new TextEncoderSettings(allowedRange))
 {
 }
 public HtmlEncoder(UnicodeRange allowedRange) : this(new CodePointFilter(allowedRange))
 { }
 public JavaScriptStringEncoder(UnicodeRange allowedRange) : this(new CodePointFilter(allowedRange))
 { }
 private static bool IsInRange(UnicodeRange range, Rune rune)
 {
     return(rune.Value >= range.FirstCodePoint && rune.Value < (range.FirstCodePoint + range.Length));
 }
 public static bool SupportsScript(FontVariant v, UnicodeRange range)
 {
     // Filters out fonts that support just a singular symbol (like currency symbol)
     return(v.UnicodeRanges.Any(r => r.First <= range.End && range.Start <= r.Last && ((r.Last - r.First) > 0)));
 }
 public HtmlEncoder(UnicodeRange allowedRange) : this(new TextEncoderSettings(allowedRange))
 {
 }
 public JavaScriptStringEncoder(UnicodeRange allowedRange) : this(new TextEncoderSettings(allowedRange))
 { }