Exemplo n.º 1
0
        public static int PrintFormatted(string format, PhpArray args)
        {
            string formattedString = PhpStrings.Format(format, args);

            ScriptContext.CurrentContext.Output.Write(formattedString);

            return(formattedString.Length);
        }
Exemplo n.º 2
0
        public static int PrintFormatted(string format, params object[] args)
        {
            string formattedString = PhpStrings.FormatInternal(format, args);

            ScriptContext.CurrentContext.Output.Write(formattedString);

            return(formattedString.Length);
        }
Exemplo n.º 3
0
        private static int SubStringCount(string haystack, string needle, getEncoding encodingGetter)
        {
            string uhaystack = ObjectToString(haystack, encodingGetter);
            string uneedle   = ObjectToString(needle, encodingGetter);

            if (uhaystack == null || uneedle == null)
            {
                return(0);
            }

            return(PhpStrings.SubstringCount(uhaystack, uneedle));
        }
Exemplo n.º 4
0
        private static string ArgToString(object var)
        {
            string s = var as string;

            if (s == null)
            {
                if (var is int)
                {
                    s = PhpStrings.ChrUnicode((int)var);
                }
            }
            return(s);
        }
Exemplo n.º 5
0
        private static Value _strtolower(FlowController flow, Value[] arguments)
        {
            Debug.Assert(arguments.Length == 1);

            stringConverter.SetContext(flow);
            var stringValue = stringConverter.EvaluateToString(arguments[0]);

            if (stringValue == null)
            {
                return(flow.OutSet.AnyStringValue);
            }

            return(flow.OutSet.CreateString(PhpStrings.ToLower(stringValue.Value)));
        }
Exemplo n.º 6
0
        private static Value _htmlentities(FlowController flow, Value[] arguments)
        {
            Debug.Assert(arguments.Length > 0);

            if (arguments.Length > 1)
            {
                // TODO: Implement precisely
                return(flow.OutSet.AnyStringValue);
            }

            stringConverter.SetContext(flow);
            var stringValue = stringConverter.EvaluateToString(arguments[0]);

            if (stringValue == null)
            {
                return(flow.OutSet.AnyStringValue);
            }

            return(flow.OutSet.CreateString(PhpStrings.EncodeHtmlEntities(stringValue.Value)));
        }