示例#1
0
        private static object Escape(object obj)
        {
            string str = obj as string;

            if (str != null)
            {
                obj = UnicodeUtil.EscapeInvalidSurrogates(str);
            }
            return(obj);
        }
示例#2
0
        private static object EscapeOrUnescape(object obj, bool escape)
        {
            string str = obj as string;

            if (str != null)
            {
                return(escape
                                        ? UnicodeUtil.EscapeInvalidSurrogates(str)
                                        : UnicodeUtil.UnescapeInvalidSurrogates(str));
            }
            object[] arr = obj as object[];
            if (arr != null)
            {
                for (int i = 0; i < arr.Length; i++)
                {
                    arr[i] = EscapeOrUnescape(arr[i], escape);
                }
            }
            return(obj);
        }