Skip to main content
jibinanto40792294
Inspiring
August 25, 2021
Question

Special Characters Not Translating

  • August 25, 2021
  • 3 replies
  • 705 views

Hi,
Using coldfusion 16 and backend sqlserver. Have a product table whose name field is of data type "nvarchar(250)". Have data to insert which contain special characters like Apostrophe (‘), Ampersand (&), Trademark (™), Circle R (®), Copyright – Circle C (©)
Now, it's storing in DB these characters like '?'.
Is it possible to store the characters as such in DB?
Please advise
This topic has been closed for replies.

3 replies

BKBK
Community Expert
Community Expert
August 29, 2021

Ensure that your ColdFusion application uses UTF-8 encoding. One way to do so is as follows:

  1. Open the ColdFusion Administrator for the particular ColdFusion instance;
  2. Navigate to the page Server Settings > Java and JVM;
  3. Inspect the content of the field JVM Arguments. Does it include the setting -Dfile.encoding=UTF-8 ?
    If so, then the application uses UTF-8 encoding, and there's no need to proceed any further. We have to look for the cause of the problem elsewhere.
    If not, then you have to include UTF-8 encoding in your Java settings.
  4. To include UTF-8 encoding, place your mouse cursor at the end of the text in the JVM Arguments field. Press space-bar of your keyboard to create a space. Type -Dfile.encoding=UTF-8 and press the button to Submit Changes.
  5. Restart the ColdFusion instance. 

 

Does that solve the problem?

Community Expert
August 25, 2021

If you're seeing those characters, it could be because you're not saving them as Unicode, or because you're not retrieving them as Unicode. Try each of those things separately. Look at SQL Server directly using SQL Server Management Console or whatever it's called nowadays, and run a query to fetch them. If they're still showing up as question marks, that indicates you're not saving them as Unicode. Otherwise, you're retrieving and/or displaying them in a way that doesn't support Unicode.

 

If you're not saving them as Unicode, check your SQL Server data source to make sure that the Unicode box is checked under "Advanced Settings" if I recall correctly. That's the most likely problem, I think. See how that works and let us know.

 

Dave Watts, Eidolon LLC

Dave Watts, Eidolon LLC
jibinanto40792294
Inspiring
August 26, 2021

Thanks for the guidance.
While trying directly from SQL Server Management Console window, the special characters are saved to table
column correctly.But while trying to insert using cf code, ie reading the special character text from a csv file
and importing to sql table,it is not getting saved properly.


Tried with above mentioned unicode settings from cf admin datasource advance settings area, restarted both cf service and system,still saving incorrectly.

Please advise

Participating Frequently
August 26, 2021

You also need to set the character encoding to UTF-8 so the characters coming in do not get stripped.

 

In the application.cfc add 

  SetEncoding("form","utf-8");
  SetEncoding("url","utf-8");
 
Also on your page display include the following in the HTML header
  <meta charset="utf-8">
 
Participant
August 25, 2021
I want to cancel the subscription for this
Community Expert
August 25, 2021

Dave Watts, Eidolon LLC