Having experienced this far too many times (dogs jumping fences!) I now carry a few compressed air devices (“Pet Convincer” is a repurposed CO2 tire inflator that blasts air) to scare off-leash dogs away without hurting your dog accidentally via other less humane methods (pepper spray, tazer, etc).
Keep your dogs on a leash in public people!