Is there any official source that tells if "with" or "without space" should be used one instead of the other, or if they both are officially accepted, when should one be used and when the other?
It's a good question, because I have the same question. The short answer, is IATA seems to be inconsistent on the issue. It doesn't give a lot of examples, but in some cases it's no space, some cases it is a space. I spent some time leafing through the IATA Passenger Service Conferences Manual and the IATA Ticketing Handbook, as a person does on a Friday night, and I did not find a definitive preference or declaration.
These documents are in copyright and regrettably I cannot provide references.
IATA tends to treat the carrier, or airline designator, as a separate field to the flight number. Thus on forms and in tables, they are shown separately. In running text, IATA usually writes a flight designator with a non-breaking space between the airline designator and the flight number.
The exceptions I find are examples of monospaced printed information or display screens where sometimes (but not universally) the airline designator and flight number appear unseparated.
I tried to find out if there was an official practice. The best I could find was Resolution 761, "Flight Numbers", which looked promising ...
- A flight number shall contain up to four (4) digits (to be prefixed by a two-character or three-letter airline designator) ...
Regrettably, no word on spacing.
- For Schedule Exchange purposes only, the format of flight numbers may be as prescribed by the Standard Schedules Information Manual (SSIM) (see Recommended Practice 1761b) ...
It turns out that IATA Recommended Practice 1761b, first adopted July 1972, simply recommends that member airlines use the IATA Standard Schedules Information Manual when exchanging airline schedule information with each other. The SSIM is also silent on the issue, but its examples always have the flight designator without space. That said, the document intends to describe electronic distribution, and if you know the format in advance, the space is just an extra byte which is just cost.
If we focus on 2-letter IATA flight codes (discard 3-letter ICAO for this question)
IATA resolved (Resolution 001pg) at the 1994 passenger services conference that three-letter airline designators should be allowed (that's specifically three letters, not two characters like for the existing airline designators). I don't believe that provision was ever activated, but no doubt a lot of IT consultants made a lot of money preparing for it.
This is important to your question, because in most places where a fixed width airline designator or carrier code is required, IATA sets the field at three characters wide. For two-character airline designators, the third character is a space. Therefore a lot of the time you see two characters in a monospaced output, it could be that the third character is a blank, and not a separator.
I'm doing documentation for travelers and frequently I wonder if I should write "XX nnnn" or "XXnnnn"
The flight designator can also have a letter suffix. This is sometimes used if the same flight number has to be reused on the same day for the same route (which is not allowed), for instance if
AB 123 is grounded at an out station and delayed by 14 hours, there could be two
AB 123s the next day. One of the flights is usually re-designated
AB 123Z, depending on the airline's practice.