fCraft.Chat.ReplaceEmotesWithUncode C# (CSharp) Method

ReplaceEmotesWithUncode() private method

private ReplaceEmotesWithUncode ( [ input ) : string
input [
return string
        public static string ReplaceEmotesWithUncode( [NotNull] string input ) {
            if ( input == null )
                throw new ArgumentNullException( "input" );
            StringBuilder sb = new StringBuilder( input );
            for ( int i = 1; i < UnicodeReplacements.Length; i++ ) {
                sb.Replace( ( char )i, UnicodeReplacements[i] );
            }
            sb.Replace( '\u007F', '⌂' );
            return sb.ToString();
        }

Usage Example

Example #1
0
        public static void Log(LogType type, [NotNull] string message, [NotNull] params object[] args)
        {
            if (message == null)
            {
                throw new ArgumentNullException("message");
            }
            if (args == null)
            {
                throw new ArgumentNullException("args");
            }
            if (!Enabled)
            {
                return;
            }

            if (args.Length > 0)
            {
                message = String.Format(message, args);
            }
            // occasionally \r\n newlines slip into the system, e.g. in stack traces
            message = message.Replace("\r\n", "\n");
            message = Chat.ReplaceNewlines(message);
            message = Chat.ReplaceEmotesWithUncode(message);
            message = Color.StripColors(message);

            string line = DateTime.Now.ToString(TimeFormat) + " > " + GetPrefix(type) + message;     // localized

            lock ( LogLock ) {
                RaiseLoggedEvent(message, line, type);

                RecentMessages.Enqueue(line);
                while (RecentMessages.Count > MaxRecentMessages)
                {
                    RecentMessages.Dequeue();
                }

                if (LogFileOptions[(int)type])
                {
                    try {
                        File.AppendAllText(Path.Combine(Paths.LogPath, CurrentLogFileName),
                                           line + Environment.NewLine);
                    } catch (Exception ex) {
                        string errorMessage = "Logger.Log: " + ex;
                        line = String.Format("{0} > {1}{2}",
                                             DateTime.Now.ToString(TimeFormat),   // localized
                                             GetPrefix(LogType.Error),
                                             errorMessage);
                        RaiseLoggedEvent(errorMessage,
                                         line,
                                         LogType.Error);
                    }
                }
            }
        }