DBD::ODBC has had increasing support for unicode since version 1.16. However, unicode seems to be an issue that causes a lot of confusion and especially when it comes to DBI and DBDs. The mantra of just DWIM, is complicated because most DBDs were originally written with no unicode support. Changing them to automatically do the right thing when adding support for unicode inevitably breaks a lot of existing code e.g., people storing UTF-8 in varchars who decode the data coming back from the database would suddenly find their code breaks if their UTF-8 encoded perl scalars suddenly ended up in the database as database-encoded-unicode and did not need decoding when selected back. This is why a lot of DBDs have an attribute to enable unicode support.
DBD::ODBC was rather fortunate in that the ODBC specification was enhanced to add new unicode APIs and new data types called SQL_WCHARs which meant there appeared to be a clear division between the old ANSI APIs and the newer unicode (so called Wide) APIs. However, nothing is a simple as it first seems and some of the problems I ran in to were:
Mostly, all these issues are resolved now although, even now on Unix, DBD::ODBC builds by default without unicode support mostly because so many people seem to have old code they depend on so switching to a unicode build needs to be a positive decision.
So, sitting back quite happy about the current support for unicode in DBD::ODBC I was surprised to be seeing increasing questions and confusion about it. It seems:
There isn't a whole lot I can do about the first 3 of those above but I thought a few minor faqs in DBD::ODBC might help. So I collected together the issues I'd seen and started writing a few FAQs and the more I wrote down the more I realised what I knew was so "every day" for me I'd lost sight that it is quite complicated and confusing. So I'm attempting to put together a more thorough document and so far I have a common problems document and some examples.
I'd be really pleased if you could read over these and suggest improvements. I'd also be happy to receive any ideas for areas I've not convered that have confused you or even issues you still have and have not resolved. Of course, I'm not really opening this up to any DBD right now and would prefer to keep it DBD::ODBC for the moment but I'm happy to compile any problems/misconceptions if they include solutions/explanations for other DBDs too.