How to Force Utf-8 Encoding in Browser

How to force UTF-8 encoding in browser?

Disable default charset:

AddDefaultCharset Off

How to force browser to use UTF-8?

Add in .htaccess

php_value default_charset None 
AddDefaultCharset UTF-8

getting UTF-8 text files to display on all browsers

A browser will not know the text is UTF-8 encoded unless the text starts with a UTF-8 BOM (assuming the browser even looks for that) or the HTTP Content-Type header specifies UTF-8 as the Charset, ie: Content-Type: text/plain; charset=utf-8. If AddCharset tells Apache to generate that attribute for .txt files, then great.

There is no way to specify a font for a .txt file by itself. You have to use HTML for that. To specify a font for a .txt file, you would have to write a server-side script that outputs an HTML wrapper around the .txt file content and then sets the HTTP Content-Type header to specify text/html instead of text/plain as the data type.



Related Topics



Leave a reply



Submit