ascii v. binary

in the past few days i've been working with programs that deal with files. mostly what i'm writing is unsigned chars. the significance of the data is in the bits of each char.
some chars are carriage returns or other special characters. this affects linux and windows differently, and it messes the stream up from encode to decode (producing garbage for the rest of the stream).

is there a universally accepted way to write and read in binary in c++? without changing anything for a different os?