Nowdays when you say 20 mA current loop, someone might think 4-20 mA or 0-20 mA for transmission of analog signals. Not the case here.
This really looks like current loop to RS232. The older standards for RS232 were -24 to -3 and +3 to +24 volts. This uses closer to +12 and -12. Rs232 does go as low as -5 and +5 and then there is RS232TTL which is usually inverted.
I don;t know what the 9639 is, but lets just assume it's an OP Amp for now. It's really acting as a comparitor. A reference is set with a voltage divider which sets the voltage at 2.55V. The 10K and 2.7K. The 220 resistor is where the X mA will be impressed on. It should be (5-0,6)/1220. So, when the voltage is >2.55 V, the OP amp switches state. I think the diode is adding some reverse polarity protection and the transistor inversion. The secondary current is (5-0.6)/1220 or at least 4 mA. Something seems fishy with my calculations. So, if the power supply was bigger (+12 instead of +5 on the OPTO) and/or the 1K resistor smaller, it would make sense.
It's been a while and I forget the quiescent state and the definition of mark and space, but switching the inputs tot he OP amp, just reverses the output. Mark and Space never concerned me because I always used a breakout box.
There are standard RS232 converter chips that probably could be used.