Then I read some wiki that said those flags meant "I wish you a pleasant voyage" which didn't seem to have anything to do with UW. But that's because I didn't know about The International Code of Signals. These are protocols by which folks on one ship can contact folks on another ship and convey the notion "I would like to communicate by means of semaphore flags." You could just start waving semaphore flags, but if the folks on the other ship want to use some other method, how do you work that out? The Code of Signals isn't just a code-as-in-protocol. It's also a code-as-in-encoding. It defines some things like "UW" means "I wish you a pleasant voyage."
There are also shorthand ways to say, "We are going to jump by parachute" (BO), "Further explosions are possible" (JD3), and "My vessel is a dangerous source of radiation" (MS). You know, the kind of everyday shipboard phrases you don't want to have to spell out each time. I guess?
I'd seen books of merchant codes. If you were a New York manufacturer who wanted news from your traveling salesman in Omaha, you wanted him to telegraph you. But since telegraph companies and clerks were often into industrial espionage, you wanted to use a code. So each big company had a code with boring shorthand ways to say boring things like "5 bushels of oats at the agreed-upon price." But the International Code of Signals has more drama. "I have to cut the warps. The trawls are entangled" (TU). That's some delicate news to convey, right there.