Opc.Ua.Com.Client.ParsedNodeId.ExtractAndUnescapeString C# (CSharp) Method

ExtractAndUnescapeString() protected static method

Extracts the and unescapes a string.
protected static ExtractAndUnescapeString ( string text, int &start ) : string
text string The text.
start int The start.
return string
        protected static string ExtractAndUnescapeString(string text, ref int start, params char[] specialChars)
        {
            StringBuilder buffer = new StringBuilder();

            int index = start;
            bool escaped = false;

            while (index < text.Length)
            {
                char ch = text[index++];

                if (!escaped)
                {
                    // skip any escape character but keep the one after it.
                    if (ch == specialChars[0])
                    {
                        escaped = true;
                        continue;
                    }

                    // terminate on any special char other than the escape char.
                    for (int jj = 1; jj < specialChars.Length; jj++)
                    {
                        if (specialChars[jj] == ch)
                        {
                            start = index-1;
                            return buffer.ToString();
                        }
                    }
                }

                buffer.Append(ch);
                escaped = false;
            }

            start = text.Length;
            return buffer.ToString();
        }
        #endregion