コード例 #1
0
ファイル: Utf8String.cs プロジェクト: jkotas/corefxlab
        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);
        }
コード例 #2
0
        public Utf8String TrimEnd()
        {
            CodePointReverseEnumerator it = CodePoints.GetReverseEnumerator();

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

            return(Substring(0, it.PositionInCodeUnits));
        }
コード例 #3
0
ファイル: Utf8String.cs プロジェクト: jkotas/corefxlab
        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));
        }