Example #1
0
        public Utf8String TrimEnd()
        {
            CodePointReverseEnumerator it = CodePoints.GetReverseEnumerator();

            while (it.MoveNext() && UnicodeCodePoint.IsWhitespace(it.Current))
            {
            }

            return(Substring(0, it.PositionInCodeUnits));
        }
Example #2
0
        public int LastIndexOf(uint codePoint)
        {
            CodePointReverseEnumerator it = CodePoints.GetReverseEnumerator();

            while (it.MoveNext())
            {
                if (it.Current == codePoint)
                {
                    // Move to beginning of code point
                    it.MoveNext();
                    return(it.PositionInCodeUnits);
                }
            }

            return(StringNotFound);
        }
Example #3
0
        public Utf8String TrimEnd(Utf8String trimCharacters)
        {
            if (trimCharacters == Empty)
            {
                // Trim Whitespace
                return(TrimEnd());
            }

            CodePointReverseEnumerator it       = CodePoints.GetReverseEnumerator();
            CodePointEnumerator        itPrefix = trimCharacters.GetCodePointEnumerator();

            while (it.MoveNext())
            {
                bool found = false;
                // Iterate over prefix set
                while (itPrefix.MoveNext())
                {
                    if (it.Current == itPrefix.Current)
                    {
                        // Character found, don't check further
                        found = true;
                        break;
                    }
                }

                if (!found)
                {
                    // Reached the end, char was not found
                    break;
                }

                itPrefix.Reset();
            }

            return(Substring(0, it.PositionInCodeUnits));
        }