Homogenization and characterization of metasurfaces: General framework