MANILA — President Rodrigo Duterte of the Philippines, known for his long history of crude remarks about women, including jokes about rape, has signed a law that criminalizes wolf-whistling, catcalling and other forms of sexual harassment in public spaces.

Called the Safe Spaces Act, the law was signed in April, but it was only made public this week, the president’s spokesman, Salvador Panelo, said.

The law bans sexual harassment in all public spaces, including work places, recreational areas and public transport vehicles, and it penalizes groping, stalking and making misogynistic, homophobic, transphobic or sexist slurs. Offenses are punishable by up to 500,000 pesos, or about $9,750.

It also covers online harassment and physical, psychological and emotional threats made through private messages, in chat rooms or in public.