How to display UTF-8 characters on a LiveCode website

Learn how to display UTF-8 characters on a website running LiveCode Server in this quick and easy tutorial.

UTF-8 allows for the proper display of a number of special characters, and is also essential for multilingual characters.

We recommend using UTF-8 output for all of your websites, including LiveCode-powered websites, even if you’re only using English for now.

Using LiveCode Server to display UTF-8 output

To display UTF-8 output using LiveCode Server, simply insert a put header line at the very top of your .lc file that appends the charset of UTF-8 to the Content-Type HTTP header.

Here’s an example of how this works:

<?lc
	put header "Content-Type: text/html; charset=UTF-8"
?>
<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
	</head>
	<body>
		<?lc
			put "<p>Hello!</p>"
			put "<p>您好!</p>"
			put "<p>வணக்கம்!</p>"
			put "<p>こんにちは!</p>"
			put "<p>Powered by LiveCode" && the version & "</p>"
		?>
		<p>Goodbye!</p>
		<p>再见!</p>
		<p>குட்பை!</p>
		<p>さようなら!</p>
	</body>
</html>

This simple method allows you to include multilingual characters as-is in both the HTML and LiveCode-parsed portions of the file.

Remember to save your .lc file in UTF-8 format. Most modern text editors support this format, often by default. Also be sure to save it in Unix format (as the servers run Unix), not Windows or Mac.

Should you run into any issues or require further assistance, feel free to open a Client Care ticket via the Client Lounge, and we would be happy to assist.


You may also like:


Love our articles? HostM offers professional and helpful web hosting services with unlimited features and renewal rates that actually match our advertised rates.