Fixes h() to not return empty string when input contains invalid code unit requence. Fixes #3561