I'm currently writing an instant messaging program and I need a way to specify what kind of data is being sent. I decided to use escape sequences:
\c - Command (sent to other clients, e.g. to tell them to connect a new user)
\a - Audio (to be streamed to the user)
\i - Image (to be shown on the GUI)
\s - String (to be printed as a message)
\v - Video (to be streamed to the user)
Upon compilation, gcc warns me that \c, for example, is not recognised as an escape character. I'm wondering if this really matters. Will there be any bad side-effects to using escape sequences and, if so, what alternative is there?
I know, I'm asking if using escapes that aren't defined is acceptable. \a is defined as the 'alert' sound and '\v' is defined as vertical tab. What I'm asking is whether using \c, \i and \s (which aren't defined as escape sequences) will have any side-effects.
Just prefix all types of messages with a byte that indicates the message type. This can be a character, but it doesn't have to be.
If someone actually sends a string "cool", it would be sent as "scool", so there is no ambiguity.
That doesn't work, though. How can the program know what characters are included by the user? I'm not writing a language parser... That's why I used escapes. If the user types "\a" I'll see it as "\\a" so it won't matter.
Edit: Wait, never mind. I think you're right. The client knows what data it's sending before sending it, so the [hypothetical] command "ool" which would be sent as "cool" would be different from the string "cool" which would be sent as "scool". Ok, thanks.