html - PHP convert characters applicable for title tag -
in page convert lower uppercase string , output 'em in title tag. first had issue
not accepted, had preserve entities.
so converted them unicode, uppercase , htmlentities
:
echo htmlentities(strtoupper(html_entity_decode(ob_get_clean())));
now have problem recognized related "right single quote". i'm getting character ’
in title.
it seems either of 2 functions i'm using not convert them correctly. there better function can use or there title tag?
edit: here var_dump of original data don't have influence to:
string(74) "example example example » john doe- who’s that? "
edit ii: code above results in:
this happen, if use strtoupper
:
your problem strtoupper
destroy utf-8 entity-decoded input because not multibyte aware. in instance, ’
decodes hex-encoded utf-8 sequence e2 80 99
. in strtoupper
's single-byte world, character code \xe2
â
, converted Â
(\xc2
) -- makes text invalid utf-8 sequence.
simply use mb_strtoupper
instead.
Comments
Post a Comment