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.
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:
Get a LiveCode Desktop or Mobile App to Communicate with a MariaDB/MySQL Database
LiveCode Server vs LiveCode HTML5: which should I use for my web project?
Love our articles? HostM offers professional and helpful web hosting services with unlimited features and renewal rates that actually match our advertised rates.
From $2.48/mo
We can help you move your
email and websites as desired.