Example #1
0
        public bool IsValidIdentifier(string value)
        {
            if (value.Length == 0)
            {
                return(false);
            }

            foreach (var sym in value)
            {
                if (!Parser.IsIdentifier(sym))
                {
                    return(false);
                }
            }

            return(true);
        }
Example #2
0
        public string CreateEscapedIdentifier(string value)
        {
            var result = new StringBuilder(value.Length * 5);

            foreach (var sym in value)
            {
                if (Parser.IsIdentifier(sym))
                {
                    result.Append(sym);
                }
                else
                {
                    result.Append('_');
                    result.Append(((int)sym).ToString("x"));
                }
            }

            return(result.ToString());
        }