This has probably been written about many times before, but it stumped me today, so I thought I would share in case it saves anyone else some time. By default, ColdFusion does not store data as UTF-8 into SQL Server. This is a problem for Chinese characters sets, as well as many others. I struggled with this for a while, and found partial answers in several articles online. Here is the formula…
1. Set your data type to nvarchar in your database table.
2. In ColdFusion Administrator, in your datasource settings, click 'Show Advanced Settings', and be sure to check the box for 'Enable High ASCII characters and Unicode for data sources configured for non-Latin characters'.
3. In your form processing script (where you are doing your CF database insert), include the following lines:
Step 3 should not be necessary in the newer versions of ColdFusion, but it does not hurt anything to include it.
With these three steps completed, all of our form data that included extended characters started working.
4 Replies to “UTF-8 and Other Character Sets with ColdFusion”
I did all of those and it doesn’t work. Trying to enter chinese.
SQL 2008 – column is NVARCHAR
Monique, did you also confirm that in the ColdFusion Administrator you have ‘Enable High ASCII characters and Unicode for data sources configured for non-Latin characters’ checked for the data source you are using?
Yes. that is checked. Weird this is that everything works on my local version of CF but not on the DEV server. Both datasources have the “Enable High ASCII characters…” option checked. Could there be some other server settings that are preventing it?
In the SQL statement that is adding the text, is it using N’YOURVALUEHERE’?
insert into yourtable (yourcolumn)