A Swedish man caught masturbating in public has been acquitted – but if he'd been caught elsewhere what kind of punishment might he have faced?

A 65-year-old man found masturbating openly on a Stockholm beach has been cleared of charges of sexual assault after the court ruled his activities were not directed towards a specific person. The judgment may come as a surprise but when it comes to penal codes and masturbation, the international legal system looks like a patchwork quilt.

Indonesia: decapitation

Most search results would have you believe that "the penalty for masturbation in Indonesia is decapitation". But hold your … er … horses! A formal query made to the secretary of information at the Indonesian embassy reveals that according to Article 281 of national law, the maximum sentence is 32 months' imprisonment.

UK: 14 days in prison

There are several laws that cover exposure. An 1885 legal reform known as the Labouchere Amendment had an unforeseen loophole that suddenly made masturbation (as well as fellatio) legal. Masturbating in public remains prohibited, though, because of several other laws, the key one being Section 28 of the Town Police Clauses Act 1847 which states it is an offence for anyone to "wilfully and indecently" expose his "person" in a street or public place to the obstruction, annoyance or danger of residents or passengers (NB references to a "person" mean "penis"). The overall penalty incurred is dependent on a range of circumstantial factors.

Brazil: special circumstances

In 2011, a Brazilian woman took her employers to court after doctors gave evidence about her need to masturbate up to 47 times a day. The court ruled that she was legally entitled to a 15-minute break every two hours.

Saudi Arabia: 3 years and 300 lashes

In March 2004, a general court sentenced a teacher to three years in prison and 300 lashes for declaring that masturbation (as well as homosexuality, smoking and music) were permissible under Islam.

Alabama: illegal if it's artificial

In the US, laws vary from state to state. In 2009, the supreme court of Alabama outlawed the sale of "any device designed … primarily for the stimulation of human genital organs" in an effort to target sales of masturbation machines.

Photograph: PR shot

North Carolina: criminal record

In the city of Charlotte, being caught masturbating in public is a class 3 misdemeanour. Luckily a local attorney is on hand with advice that includes asking the right questions: "Stroking? Ejaculation? Does the defendant have a clean record?"

Texas: two years in prison

According to the Tribune Herald, a new measure which will come into force on 1 January 2014 will make many forms of male masturbation illegal. "Exceptions include sperm donations, which now must only be performed at a designated hospital facility."

Texas has already been gripped by a mass debate about onanism after Michael Burgess, a member of the house of representatives, claimed that abortion should be banned at 15 weeks because that is the age at which male foetuses are able to masturbate.