wp_insert_post and title not utf8 inserts with empty title?

I'm using wp_insert_post I loop over a text file one row at a time and for each row I create a post. The text is set as the `post_title', for text that is not utf8 the post inserts but with an empty title.

Why does that happen, if I'm able to create a post in the backend admin using non utf8 chars it looks like WordPress converts the encoding in the backend.

How can I bypass this with wp_insert_post and have it insert the post title with non utf8 chars?

Thanks

Topic wp-insert-post Wordpress encoding

Category Web


It could be due to the text encoding you are using is not set to UTF8, try to use iconv() and set.

iconv('ISO-8859-1','UTF-8', $post_info['post_content']);

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.