Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can UTF-8 encoded characters be used in a page title?

I would have expected that the page title respected the charset, but I'm seeing differently. Setting document.title to Fo'o Bar doesn't result in Fo'o Bar being printed as the page title. My browser encoding is set to UTF-8, I am declaring the charset in a meta tag, and the file is saved as UTF-8. It seems like my only option is to use JavaScript to create a DOM node and then set the document.title to the text from that node. Is this right?

like image 908
glevine Avatar asked Jan 24 '26 17:01

glevine


1 Answers

Set your title like this:

document.title = 'Fo\u0027o Bar';

See the MDN for full documentation on escaping Unicode characters.

like image 81
Cameron Tinker Avatar answered Jan 27 '26 06:01

Cameron Tinker



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!