Client Area
All-in-one service management,
billing & support, conveniently & securely
in one single feature rich place.

Portal Home > Knowledgebase > Windows Hosting > Windows (Helm USA) > ColdFusion > How to use Unicode in Coldfusion - mulitlanguage databases and pages

How to use Unicode in Coldfusion - mulitlanguage databases and pages

If you want to create/use multilanguage database records and display them on your pages, you'll have to keep the following points in mind.


When setting up your database, your tables must be able to store the data as unicode. For MSSQL 2000 you'll need to use nchar, nvarchar and ntext instead of char, varchar and text for datatypes of your columns.

When you submit a support ticket for setting up a Coldfusion DSN, please tell us that your DSN needs to support Unicode (UTF-8) so we now we have to set specific settings for that connection


When inserting data into the database, you'll need to specify which part of the data needs to be inserted as unicode values. Here is an example of how it is done with the cfquery tag:
<cfquery datasource="foo">

INSERT INTO table_foo(name, continent, usernotes)
VALUES (N'Michael', N'eu', N'Does some stuff with Coldfusion sometimes')


This example shows an N in front of all the values that needs to be inserted into unicode columns. The columns in this example are setup like this: name = nvarchar, continent = nchar and usernotes = ntext.

Coldfusion pages

To make sure that all the information that is sent is received as unicode, you need to add this code to the top of your Application.cfm
<cfset SetEncoding("form", "utf-8")/>
<cfset SetEncoding("url", "utf-8")/>

Also in the of your page, you need to set the charset to utf-8. Find this line in the head of your page:
<meta http-equiv="Content-Type" content="text/html; charset=your normal encoding" />
and change it to:
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
If it doesn't exist, be sure to add it to the tag of your page.

That's about all you need to do to get Coldfusion work with unicode. If you're still having problems getting it to work properly, please submit a support ticket and we can check your DSN to make sure it's enabled for unicode.

Was this answer helpful?

Add to Favourites Add to Favourites    Print this Article Print this Article

Also Read