コード例 #1
0
ファイル: EudcProperty.cs プロジェクト: yeungxh/TestApi
        /// <summary>
        /// Define SurrogatePairDictionary class
        /// <a href="http://www.unicode.org/charts/PDF/UE000.pdf">Newline</a>
        /// </summary>
        public EudcProperty(UnicodeRangeDatabase unicodeDb, Collection<UnicodeRange> expectedRanges)
        {
            low = 0xE000; high = 0xF8FF;

            bool isValid = false;
            foreach (UnicodeRange range in expectedRanges)
            {
                if (RangePropertyCollector.BuildPropertyDataList(
                    unicodeDb,
                    range,
                    eudcRangeList,
                    "Private Use",
                    GroupAttributes.GroupName))
                {
                    isValid = true;
                }
            }

            if(!isValid)
            {
                throw new ArgumentOutOfRangeException("expectedRanges", "EudcProperty, EUDC ranges are beyond expected range. " +
                    "Refer to Private Use range.");
            }
            
            foreach (UnicodeRangeProperty data in eudcRangeList)
            {
                if (data.Name.Equals("Private Use Area", StringComparison.OrdinalIgnoreCase))
                {
                    low = data.Range.StartOfUnicodeRange;
                    high = data.Range.EndOfUnicodeRange;
                    break;
                }
            }
        }
コード例 #2
0
ファイル: StringFactory.cs プロジェクト: yeungxh/TestApi
        private static void InitializeAlphabetRangeList( )
        {
            bool isValid = false;

            foreach (UnicodeRange range in ranges)
            {
                UnicodeRange newRange = RangePropertyCollector.GetRange(new UnicodeRange(0x0041, 0x005A), range);
                if (null != newRange)
                {
                    alphabetRangeList.Add(newRange);
                    isValid = true;
                }

                newRange = RangePropertyCollector.GetRange(new UnicodeRange(0x0061, 0x007A), range);
                if (null != newRange)
                {
                    alphabetRangeList.Add(newRange);
                    isValid = true;
                }
            }

            if (!isValid)
            {
                throw new ArgumentOutOfRangeException("StringFactory, Latin alphabet ranges for Combining mark property are beyond expected. " +
                                                      "Refer to Latin Alphabet range 0x0041 - 0x005A and 0x0061 - 0x007A." + "All " + ranges.Count + " UniCodeRange is in Latin alphabet range");
            }
        }
コード例 #3
0
        /// <summary>
        /// Define CombiningMarksProperty class
        /// <a href="http://www.unicode.org/charts/PDF/U0300.pdf">Newline</a>
        /// <a href="http://www.unicode.org/charts/PDF/U1DC0.pdf">Newline</a>
        /// <a href="http://www.unicode.org/charts/PDF/UFE20.pdf">Newline</a>
        /// </summary>
        public CombiningMarksProperty(UnicodeRangeDatabase unicodeDb, Collection <UnicodeRange> expectedRanges)
        {
            bool isValid = false;

            foreach (UnicodeRange range in expectedRanges)
            {
                if (RangePropertyCollector.BuildPropertyDataList(
                        unicodeDb,
                        range,
                        combiningMarksPropertyRangeList,
                        "Combining Diacritics",
                        GroupAttributes.GroupName))
                {
                    isValid = true;
                }
            }

            if (InitializeCombiningMarksDictionary(expectedRanges))
            {
                isValid = true;
            }

            if (!isValid)
            {
                throw new ArgumentOutOfRangeException("expectedRanges", "CombiningMarksProperty, Combining mark ranges are beyond expected range. " +
                                                      "Refer to Combining Diacritics range.");
            }
        }
コード例 #4
0
        /// <summary>
        /// Define CombiningMarksProperty class
        /// <a href="http://www.unicode.org/charts/PDF/U0300.pdf">Newline</a>
        /// <a href="http://www.unicode.org/charts/PDF/U1DC0.pdf">Newline</a>
        /// <a href="http://www.unicode.org/charts/PDF/UFE20.pdf">Newline</a>
        /// </summary>
        public CombiningMarksProperty(UnicodeRangeDatabase unicodeDb, UnicodeRange expectedRange)
        {
            bool isValid = false;

            if (RangePropertyCollector.BuildPropertyDataList(
                    unicodeDb,
                    expectedRange,
                    combiningMarksPropertyRangeList,
                    "Combining Diacritics",
                    GroupAttributes.GroupName))
            {
                isValid = true;
            }

            if (InitializeCombiningMarksDictionary(expectedRange))
            {
                isValid = true;
            }

            if (!isValid)
            {
                throw new ArgumentOutOfRangeException("CombiningMarksProperty, combining mark ranges are beyond expected range, " +
                                                      String.Format(CultureInfo.InvariantCulture, "0x{0:X}", expectedRange.StartOfUnicodeRange) + " - " +
                                                      String.Format(CultureInfo.InvariantCulture, "0x{0:X}", expectedRange.EndOfUnicodeRange) +
                                                      ". Refer to Combining Diacritics range.");
            }
        }
コード例 #5
0
        /// <summary>
        /// Define NumberProperty class,
        /// <a href="http://unicode.org/reports/tr13/tr13-5.html">Newline</a>
        /// </summary>
        public NumberProperty(UnicodeRangeDatabase unicodeDb, UnicodeRange expectedRange)
        {
            bool isValid = false;

            if (RangePropertyCollector.BuildPropertyDataList(
                    unicodeDb,
                    expectedRange,
                    numberDigitRangeList,
                    "Numbers and Digits",
                    GroupAttributes.GroupName))
            {
                isValid = true;
            }

            if (InitializeNumberCharDictionary(expectedRange))
            {
                isValid = true;
            }

            if (!isValid)
            {
                throw new ArgumentOutOfRangeException("NumberProperty, number ranges are beyond expected range, " +
                                                      String.Format(CultureInfo.InvariantCulture, "0x{0:X}", expectedRange.StartOfUnicodeRange) + " - " +
                                                      String.Format(CultureInfo.InvariantCulture, "0x{0:X}", expectedRange.EndOfUnicodeRange) +
                                                      ". Refer to latin numberals and point, percent, plus, and minus signs, and comma.");
            }
        }
コード例 #6
0
        /// <summary>
        /// Define LineBreakDictionary class,
        /// <a href="http://www.unicode.org/reports/tr29/">Newline</a>
        /// </summary>
        public TextSegmentationProperty(UnicodeRangeDatabase unicodeDb, Collection <UnicodeRange> expectedRanges)
        {
            bool isValid = false;

            foreach (UnicodeRange range in expectedRanges)
            {
                if (RangePropertyCollector.BuildPropertyDataList(
                        unicodeDb,
                        range,
                        textSegmentationRangeList,
                        "Controls",
                        GroupAttributes.Name))
                {
                    isValid = true;
                }
            }

            if (InitializeDictionaries(expectedRanges))
            {
                isValid = true;
            }

            if (!isValid)
            {
                throw new ArgumentOutOfRangeException("expectedRanges", "TextSegmentationProperty, " +
                                                      "code points for text segmentation ranges are beyond expected range. " + "Refert to Controls ranges");
            }
        }
コード例 #7
0
        /// <summary>
        /// Create a UnicodeRange instance, using the provided UnicodeChart Enum type.
        /// </summary>
        /// <param name="chart">Group name of scripts, symbols or punctuations (e.g. "European Scripts", "Punctuation", etc.)</param>
        public UnicodeRange(UnicodeChart chart)
        {
            UnicodeRange range = RangePropertyCollector.GetUnicodeChartRange(new UnicodeRangeDatabase(), chart);

            startOfUnicodeRange = range.StartOfUnicodeRange;
            endOfUnicodeRange   = range.EndOfUnicodeRange;
        }
コード例 #8
0
ファイル: NumberProperty.cs プロジェクト: yeungxh/TestApi
        /// <summary>
        /// Define NumberProperty class,
        /// <a href="http://unicode.org/reports/tr13/tr13-5.html">Newline</a>
        /// </summary>
        public NumberProperty(UnicodeRangeDatabase unicodeDb, Collection <UnicodeRange> expectedRanges)
        {
            bool isValid = false;

            foreach (UnicodeRange range in expectedRanges)
            {
                if (RangePropertyCollector.BuildPropertyDataList(
                        unicodeDb,
                        range,
                        numberDigitRangeList,
                        "Numbers and Digits",
                        GroupAttributes.GroupName))
                {
                    isValid = true;
                }
            }

            if (InitializeNumberCharDictionary(expectedRanges))
            {
                isValid = true;
            }

            if (!isValid)
            {
                throw new ArgumentOutOfRangeException("expectedRanges", "NumberProperty, number ranges are beyond expected range. " +
                                                      "Refer to latin numberals and point, percent, plus, and minus signs, and comma.");
            }
        }
コード例 #9
0
        /// <summary>
        /// Define LineBreakDictionary class,
        /// <a href="http://www.unicode.org/reports/tr29/">Newline</a>
        /// </summary>
        public TextSegmentationProperty(UnicodeRangeDatabase unicodeDb, UnicodeRange expectedRange)
        {
            bool isValid = false;

            if (RangePropertyCollector.BuildPropertyDataList(
                    unicodeDb,
                    expectedRange,
                    textSegmentationRangeList,
                    "Controls",
                    GroupAttributes.Name))
            {
                isValid = true;
            }

            if (InitializeDictionaries(expectedRange))
            {
                isValid = true;
            }

            if (!isValid)
            {
                throw new ArgumentOutOfRangeException("TextSegmentationProperty, code points for text segmentation ranges are beyond expected range, " +
                                                      String.Format(CultureInfo.InvariantCulture, "0x{0:X}", expectedRange.StartOfUnicodeRange) + " - " +
                                                      String.Format(CultureInfo.InvariantCulture, "0x{0:X}", expectedRange.EndOfUnicodeRange) + ". Refert to Controls ranges");
            }
        }
コード例 #10
0
        private static void InitializeAlphabetRangeList( )
        {
            bool isValid = false;

            UnicodeRange newRange = RangePropertyCollector.GetRange(new UnicodeRange(0x0041, 0x005A), range);

            if (null != newRange)
            {
                alphabetRangeList.Add(newRange);
                isValid = true;
            }

            newRange = RangePropertyCollector.GetRange(new UnicodeRange(0x0061, 0x007A), range);
            if (null != newRange)
            {
                alphabetRangeList.Add(newRange);
                isValid = true;
            }

            if (!isValid)
            {
                throw new ArgumentOutOfRangeException("StringFactory, latin alphabet range are beyond expected " +
                                                      String.Format(CultureInfo.InvariantCulture, "0x{0:X}", range.StartOfUnicodeRange) + " - " +
                                                      String.Format(CultureInfo.InvariantCulture, "0x{0:X}", range.EndOfUnicodeRange) +
                                                      ". Refer to latin Alphabet range 0x0041 - 0x005A and 0x0061 - 0x007A.");
            }
        }
コード例 #11
0
        /// <summary>
        /// Define SurrogatePairDictionary class
        /// <a href="http://www.unicode.org/charts/PDF/UE000.pdf">Newline</a>
        /// </summary>
        public EudcProperty(UnicodeRangeDatabase unicodeDb, UnicodeRange expectedRange)
        {
            low = 0xE000; high = 0xF8FF;
            if (!RangePropertyCollector.BuildPropertyDataList(
                    unicodeDb,
                    expectedRange,
                    eudcRangeList,
                    "Private Use",
                    GroupAttributes.GroupName))
            {
                throw new ArgumentOutOfRangeException("EudcProperty, EUDC ranges are beyond expected range, " +
                                                      String.Format(CultureInfo.InvariantCulture, "0x{0:X}", expectedRange.StartOfUnicodeRange) + " - " +
                                                      String.Format(CultureInfo.InvariantCulture, "0x{0:X}", expectedRange.EndOfUnicodeRange) + ". Refer to Private Use range.");
            }

            foreach (UnicodeRangeProperty data in eudcRangeList)
            {
                if (data.Name.Equals("Private Use Area", StringComparison.OrdinalIgnoreCase))
                {
                    low  = data.Range.StartOfUnicodeRange;
                    high = data.Range.EndOfUnicodeRange;
                    break;
                }
            }
        }
コード例 #12
0
        /// <summary>
        /// Define SurrogatePairProperty class
        /// <a href="http://www.unicode.org/charts/PDF/UD800.pdf">Newline</a>
        /// <a href="http://www.unicode.org/charts/PDF/UDC00.pdf">Newline</a>
        /// </summary>
        public SurrogatePairProperty(UnicodeRangeDatabase unicodeDb, Collection <UnicodeRange> expectedRanges)
        {
            bool isValid = false;

            foreach (UnicodeRange range in expectedRanges)
            {
                if (RangePropertyCollector.BuildPropertyDataList(
                        unicodeDb,
                        range,
                        surrogatePairRangeList,
                        "Surrogates",
                        GroupAttributes.GroupName))
                {
                    foreach (UnicodeRangeProperty data in surrogatePairRangeList)
                    {
                        if (data.Name.Equals("High Surrogates", StringComparison.OrdinalIgnoreCase))
                        {
                            highMin = data.Range.StartOfUnicodeRange;
                            highMax = data.Range.EndOfUnicodeRange;
                        }
                        else if (data.Name.Equals("Low Surrogates", StringComparison.OrdinalIgnoreCase))
                        {
                            lowMin = data.Range.StartOfUnicodeRange;
                            lowMax = data.Range.EndOfUnicodeRange;
                        }
                    }
                    isValid = true;
                }

                surrogateRange = RangePropertyCollector.GetRange(new UnicodeRange(0x10000, TextUtil.MaxUnicodePoint), range);
                if (null != surrogateRange)
                {
                    isValid = true;
                }
            }

            if (!isValid)
            {
                throw new ArgumentOutOfRangeException("expectedRanges", "SurrogatePairProperty, SurrogatePair ranges are beyond expected range. " +
                                                      "Refert to Surrogates range and UTF32.");
            }
        }
コード例 #13
0
        /// <summary>
        /// Define SurrogatePairDictionary class
        /// <a href="http://unicode.org/reports/tr9/">Newline</a>
        /// </summary>
        public BidiProperty(UnicodeRangeDatabase unicodeDb, Collection <UnicodeRange> expectedRanges)
        {
            bool isValid = false;

            foreach (UnicodeRange range in expectedRanges)
            {
                if (RangePropertyCollector.BuildPropertyDataList(
                        unicodeDb,
                        range,
                        bidiPropertyRangeList,
                        "Arabic",
                        GroupAttributes.Name))
                {
                    isValid = true;
                }

                if (RangePropertyCollector.BuildPropertyDataList(
                        unicodeDb,
                        range,
                        bidiPropertyRangeList,
                        "Hebrew",
                        GroupAttributes.Name))
                {
                    isValid = true;
                }
            }

            if (InitializeBidiDictionary(expectedRanges))
            {
                isValid = true;
            }

            if (!isValid)
            {
                throw new ArgumentOutOfRangeException("expectedRanges", "BidiProperty, Bidi ranges are beyond expected range. " +
                                                      "Refer to Arabic and Hebrew ranges.");
            }

            // Reset isValid to validate Latin range
            isValid = false;
            foreach (UnicodeRange expectedRange in expectedRanges)
            {
                UnicodeRange range = RangePropertyCollector.GetRange(new UnicodeRange(0x0030, 0x0039), expectedRange);
                if (null != range)
                {
                    latinRangeList.Add(range);
                    isValid = true;
                }

                range = RangePropertyCollector.GetRange(new UnicodeRange(0x0041, 0x005A), expectedRange);
                if (null != range)
                {
                    latinRangeList.Add(range);
                    isValid = true;
                }

                range = RangePropertyCollector.GetRange(new UnicodeRange(0x0061, 0x007A), expectedRange);
                if (null != range)
                {
                    latinRangeList.Add(range);
                    isValid = true;
                }
            }

            if (!isValid)
            {
                throw new ArgumentOutOfRangeException("expectedRanges", "BidiProperty, Bidi ranges are beyond expected range. " +
                                                      "0x0030 - 0x0039,  0x0041 - 0x005A, and 0x0061 - 0x007A ranges are needed to construct Bidi string.");
            }
        }
コード例 #14
0
        /// <summary>
        /// Define SurrogatePairDictionary class
        /// <a href="http://www.unicode.org/reports/tr15/">Newline</a>
        /// <a href="http://www.unicode.org/charts/normalization/">Newline</a>
        /// </summary>
        public TextNormalizationProperty(UnicodeRangeDatabase unicodeDb, Collection <UnicodeRange> expectedRanges)
        {
            bool isValid = false;

            foreach (UnicodeRange range in expectedRanges)
            {
                if (RangePropertyCollector.BuildPropertyDataList(
                        unicodeDb,
                        range,
                        textNormalizationRangeList,
                        "Latin",
                        GroupAttributes.Name))
                {
                    isValid = true;
                }
                if (RangePropertyCollector.BuildPropertyDataList(
                        unicodeDb,
                        range,
                        textNormalizationRangeList,
                        "CJK Unified Ideographs (Han)",
                        GroupAttributes.Name))
                {
                    isValid = true;
                }
                if (RangePropertyCollector.BuildPropertyDataList(
                        unicodeDb,
                        range,
                        textNormalizationRangeList,
                        "CJK Compatibility Ideographs",
                        GroupAttributes.Name))
                {
                    isValid = true;
                }
                if (RangePropertyCollector.BuildPropertyDataList(
                        unicodeDb,
                        range,
                        textNormalizationRangeList,
                        "Katakana",
                        GroupAttributes.Name))
                {
                    isValid = true;
                }
                if (RangePropertyCollector.BuildPropertyDataList(
                        unicodeDb,
                        range,
                        textNormalizationRangeList,
                        "Hangul Jamo",
                        GroupAttributes.Name))
                {
                    isValid = true;
                }
                if (RangePropertyCollector.BuildPropertyDataList(
                        unicodeDb,
                        range,
                        textNormalizationRangeList,
                        "Hangul Syllables",
                        GroupAttributes.Name))
                {
                    isValid = true;
                }
                if (RangePropertyCollector.BuildPropertyDataList(
                        unicodeDb,
                        range,
                        textNormalizationRangeList,
                        "Arabic",
                        GroupAttributes.Name))
                {
                    isValid = true;
                }
                if (RangePropertyCollector.BuildPropertyDataList(
                        unicodeDb,
                        range,
                        textNormalizationRangeList,
                        "Greek",
                        GroupAttributes.Name))
                {
                    isValid = true;
                }
            }


            if (InitializeTextNormalizationPropertyDictionary(expectedRanges))
            {
                isValid = true;
            }

            if (!isValid)
            {
                throw new ArgumentOutOfRangeException("expectedRanges", "TextNormalizationProperty, " +
                                                      "code points for text normalization ranges are beyond expected range. " + "Refert to Latin,  CJK Unified Ideographs (Han) " +
                                                      "CJK Compatibility Ideographs, Katakana, Hangul Jamo, Hangul Syllables, Arabic, and  Greek ranges.");
            }
        }
コード例 #15
0
ファイル: BidiProperty.cs プロジェクト: yeungxh/TestApi
        /// <summary>
        /// Define SurrogatePairDictionary class
        /// <a href="http://unicode.org/reports/tr9/">Newline</a>
        /// </summary>
        public BidiProperty(UnicodeRangeDatabase unicodeDb, UnicodeRange expectedRange)
        {
            bool isValid = false;

            if (RangePropertyCollector.BuildPropertyDataList(
                    unicodeDb,
                    expectedRange,
                    bidiPropertyRangeList,
                    "Arabic",
                    GroupAttributes.Name))
            {
                isValid = true;
            }

            if (RangePropertyCollector.BuildPropertyDataList(
                    unicodeDb,
                    expectedRange,
                    bidiPropertyRangeList,
                    "Hebrew",
                    GroupAttributes.Name))
            {
                isValid = true;
            }

            if (InitializeBidiDictionary(expectedRange))
            {
                isValid = true;
            }

            if (!isValid)
            {
                throw new ArgumentOutOfRangeException("BidiProperty, Bidi ranges are beyond expected range, " +
                                                      String.Format(CultureInfo.InvariantCulture, "0x{0:X}", expectedRange.StartOfUnicodeRange) + " - " +
                                                      String.Format(CultureInfo.InvariantCulture, "0x{0:X}", expectedRange.EndOfUnicodeRange) +
                                                      ". Refer to Arabic and Hebrew ranges.");
            }

            UnicodeRange range = RangePropertyCollector.GetRange(new UnicodeRange(0x0030, 0x0039), expectedRange);

            if (null != range)
            {
                latinRangeList.Add(range);
                isValid = true;
            }

            range = RangePropertyCollector.GetRange(new UnicodeRange(0x0041, 0x005A), expectedRange);
            if (null != range)
            {
                latinRangeList.Add(range);
                isValid = true;
            }

            range = RangePropertyCollector.GetRange(new UnicodeRange(0x0061, 0x007A), expectedRange);
            if (null != range)
            {
                latinRangeList.Add(range);
                isValid = true;
            }

            if (!isValid)
            {
                throw new ArgumentOutOfRangeException("BidiProperty, Bidi ranges are beyond expected range, " +
                                                      String.Format(CultureInfo.InvariantCulture, "0x{0:X}", expectedRange.StartOfUnicodeRange) + " - " +
                                                      String.Format(CultureInfo.InvariantCulture, "0x{0:X}", expectedRange.EndOfUnicodeRange) +
                                                      ". 0x0030 - 0x0039,  0x0041 - 0x005A, and 0x0061 - 0x007A ranges are needed to construct Bidi string.");
            }
        }
コード例 #16
0
        /// <summary>
        /// Define SurrogatePairDictionary class
        /// <a href="http://www.unicode.org/reports/tr15/">Newline</a>
        /// <a href="http://www.unicode.org/charts/normalization/">Newline</a>
        /// </summary>
        public TextNormalizationProperty(UnicodeRangeDatabase unicodeDb, UnicodeRange expectedRange)
        {
            bool isValid = false;

            if (RangePropertyCollector.BuildPropertyDataList(
                    unicodeDb,
                    expectedRange,
                    textNormalizationRangeList,
                    "Latin",
                    GroupAttributes.Name))
            {
                isValid = true;
            }
            if (RangePropertyCollector.BuildPropertyDataList(
                    unicodeDb,
                    expectedRange,
                    textNormalizationRangeList,
                    "CJK Unified Ideographs (Han)",
                    GroupAttributes.Name))
            {
                isValid = true;
            }
            if (RangePropertyCollector.BuildPropertyDataList(
                    unicodeDb,
                    expectedRange,
                    textNormalizationRangeList,
                    "CJK Compatibility Ideographs",
                    GroupAttributes.Name))
            {
                isValid = true;
            }
            if (RangePropertyCollector.BuildPropertyDataList(
                    unicodeDb,
                    expectedRange,
                    textNormalizationRangeList,
                    "Katakana",
                    GroupAttributes.Name))
            {
                isValid = true;
            }
            if (RangePropertyCollector.BuildPropertyDataList(
                    unicodeDb,
                    expectedRange,
                    textNormalizationRangeList,
                    "Hangul Jamo",
                    GroupAttributes.Name))
            {
                isValid = true;
            }
            if (RangePropertyCollector.BuildPropertyDataList(
                    unicodeDb,
                    expectedRange,
                    textNormalizationRangeList,
                    "Hangul Syllables",
                    GroupAttributes.Name))
            {
                isValid = true;
            }
            if (RangePropertyCollector.BuildPropertyDataList(
                    unicodeDb,
                    expectedRange,
                    textNormalizationRangeList,
                    "Arabic",
                    GroupAttributes.Name))
            {
                isValid = true;
            }
            if (RangePropertyCollector.BuildPropertyDataList(
                    unicodeDb,
                    expectedRange,
                    textNormalizationRangeList,
                    "Greek",
                    GroupAttributes.Name))
            {
                isValid = true;
            }


            if (InitializeTextNormalizationPropertyDictionary(expectedRange))
            {
                isValid = true;
            }

            if (!isValid)
            {
                throw new ArgumentOutOfRangeException("TextNormalizationProperty, code points for text normalization ranges are beyond expected range, " +
                                                      String.Format(CultureInfo.InvariantCulture, "0x{0:X}", expectedRange.StartOfUnicodeRange) + " - " +
                                                      String.Format(CultureInfo.InvariantCulture, "0x{0:X}", expectedRange.EndOfUnicodeRange) + ". Refert to Latin,  CJK Unified Ideographs (Han) " +
                                                      "CJK Compatibility Ideographs, Katakana, Hangul Jamo, Hangul Syllables, Arabic, and  Greek ranges.");
            }
        }