Viewing By Entry / Main
April 17, 2004
enable unicode dsn option's secret revealed
let me first ask what you think this label means, Enable Unicode for data sources configured for non-Latin characters? if you're like me, you'd probably think it meant that enabling this puppy would force the db driver (sql server in my case) to use Unicode for all text to/from the database. and as it turns out you (and me) would be wrong. now let me backtrack a bit and explain that with sql server you'd normally use unicode hinting--the "N" in N'test'-- to let the db know that a particular chunk of text is actually Unicode. so if you understood Enable Unicode as to actually enable unicode you might be tempted to not use Unicode hinting in your cf sql code. and of course you'd garbage your text data as a result. you might be asking why i'd never picked up this before now (heck blackstone's just around the corner)? because i'm what some folks might call nutso about Unicode, i always go the extra mile in dealing with Unicode--i always use Unicode hinting even when i enabled the Unicode option for a given dsn. so this is an issue i'd never noticed before.

so what exactly does Enable Unicode enable? why it controls how the cfqueryparam deals with Unicode text. if you turn it on, cfqueryparam handles Unicode text correctly. turn it off and cfqueryparam turns your Unicode text into a mound of garbage.

let me thank figleaf's steve drucker for bringing this issue up in first place (in the forums) and mm's hiroshi okugawa for digging up an mx 6.0 box to test that Enable Unicode has always worked this way.

so now you know.

update: for ray's blog users, here's what you should be looking for in your cfadmin (under the advanced menu for the blog DSN):

look at that

Comments

really cool. Helps me a lot Thanks a lot


ありがとう!


i don't believe this. I whish I knew before this. I went crazy when I switched to SQLServer and I had to add 'N' to my all queries.

still thank you Paul.


I'm trying to install BlogCFC on a shared host, and getting their support team to enable Unicode in the CF Datasource is not going well.

As a last resort, I'd like to use N' hinting, but Ray has used cfqueryparam for all his queries, and I can't figure out how to combine the two.

Any ides if this is possible, or do I have to rewrite all his queries and lose the prepared statements?


Response to Self:

Changed cfsqltype="CF_SQL_VARCHAR" to cfsqltype="CF_SQL_CLOB" in all the CFQUERYPARAM tags, and now my Japanese is displaying fine. Haven't seen any side-effects yet.


Oh I love you I spent so long trying to work this one out.