One way this is done is to frame the data. This is often done use DLE STX bytes to signal the start of transmission and DLE ETX to signal the end. Within the data, a value pair of DLE STX or DLE ETX gets escaped (preceded) with another DLE, which is then stripped out at the receiving end.
STX has a value of 0x02, ETX a value of 0x03 and DLE is 0x10.
The following is the best description I could find online:http://www.cc.gatech.edu/classes/AY2005/cs4251_fall/class14.ppt#669,2,Character-Oriented
Hey, thanks. That seems to be quite a smart way of doing it. I've been looking for something like that online, but wasn't sure what keyword to search for... :