System.Globalization.TextInfo.IsWordSeparator C# (CSharp) Method

IsWordSeparator() private method

private IsWordSeparator ( UnicodeCategory category ) : bool
category UnicodeCategory
return bool
        private bool IsWordSeparator(UnicodeCategory category) {
            return (wordSeparatorMask & (1 << (int)category)) != 0;
        }

Usage Example

        /// <summary>Converts the specified string to title case (except for words that are entirely in uppercase, which are considered to be acronyms).</summary>
        /// <param name="str">The string to convert to title case. </param>
        /// <returns>The specified string converted to title case.</returns>
        /// <exception cref="T:System.ArgumentNullException">
        ///         <paramref name="str" /> is <see langword="null" />. </exception>
        // Token: 0x060030A3 RID: 12451 RVA: 0x000B9EFC File Offset: 0x000B80FC
        public string ToTitleCase(string str)
        {
            if (str == null)
            {
                throw new ArgumentNullException("str");
            }
            if (str.Length == 0)
            {
                return(str);
            }
            StringBuilder stringBuilder = new StringBuilder();
            string        text          = null;

            for (int i = 0; i < str.Length; i++)
            {
                int             num;
                UnicodeCategory unicodeCategory = CharUnicodeInfo.InternalGetUnicodeCategory(str, i, out num);
                if (char.CheckLetter(unicodeCategory))
                {
                    i = this.AddTitlecaseLetter(ref stringBuilder, ref str, i, num) + 1;
                    int  num2 = i;
                    bool flag = unicodeCategory == UnicodeCategory.LowercaseLetter;
                    while (i < str.Length)
                    {
                        unicodeCategory = CharUnicodeInfo.InternalGetUnicodeCategory(str, i, out num);
                        if (TextInfo.IsLetterCategory(unicodeCategory))
                        {
                            if (unicodeCategory == UnicodeCategory.LowercaseLetter)
                            {
                                flag = true;
                            }
                            i += num;
                        }
                        else if (str[i] == '\'')
                        {
                            i++;
                            if (flag)
                            {
                                if (text == null)
                                {
                                    text = this.ToLower(str);
                                }
                                stringBuilder.Append(text, num2, i - num2);
                            }
                            else
                            {
                                stringBuilder.Append(str, num2, i - num2);
                            }
                            num2 = i;
                            flag = true;
                        }
                        else
                        {
                            if (TextInfo.IsWordSeparator(unicodeCategory))
                            {
                                break;
                            }
                            i += num;
                        }
                    }
                    int num3 = i - num2;
                    if (num3 > 0)
                    {
                        if (flag)
                        {
                            if (text == null)
                            {
                                text = this.ToLower(str);
                            }
                            stringBuilder.Append(text, num2, num3);
                        }
                        else
                        {
                            stringBuilder.Append(str, num2, num3);
                        }
                    }
                    if (i < str.Length)
                    {
                        i = TextInfo.AddNonLetter(ref stringBuilder, ref str, i, num);
                    }
                }
                else
                {
                    i = TextInfo.AddNonLetter(ref stringBuilder, ref str, i, num);
                }
            }
            return(stringBuilder.ToString());
        }
All Usage Examples Of System.Globalization.TextInfo::IsWordSeparator