Skip to main content
Nov 19, 2009 7:25 PM UTC
Question

outputting cyrillic from mysql database

I've tried everything

I've added ?useUnicode=true&characterEncoding=utf8 to my odbc connection string

I've downloaded and tried using the mysql jdbc 5 driver with and without ?useUnicode=true&characterEncoding=utf8

I've added <cfprocessingdirective pageEncoding="utf-8">

I've added <cfcontent type="text/html; charset=UTF-8">

I've added <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

I've added <cfquery name="test" datasource="jdbcTest">
                   set names 'utf8'
               </cfquery>

The characters are in the tables properly because php scripts pull them out properly.

here's the code I'm using to test the functionality

<cfprocessingdirective pageEncoding="utf-8">
<cfcontent type="text/html; charset=UTF-8">
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>


<body>
    <cfquery name="test" datasource="jdbcTest">
        set names 'utf8'
    </cfquery>
    <cfquery name="test" datasource="jdbcTest">
        select products_name from products_description order by products_name desc;
    </cfquery>
  
    <cfoutput>
        #test.products_name#<br />
    </cfoutput>
</body>
</html>

in the databse: Дослідники Археології Україн

on the page: Лекції з Ñ–Ñ&#129;торії українÑ&#129;ької літер

I'm at a loss.

    This topic is closed to new replies. Start a new post to keep the conversation going.

    14 replies

    Dec 1, 2009 11:55 PM UTC

    So i've found the problem, or at least a solution.

    When I inserted everything into the dev db from the utf8 encoded text file attached in my previous post, I did not at the following 2 lines of code at the top of the text file

    SET NAMES utf8;
    set character_set_server = utf8;

    now coldfusion using both the jdbc and odbc drivers (with the connection string for utf 8) pull the characters properly!

    Translate
    Inspiring
    Nov 24, 2009 5:31 PM UTC

    This might be a bit shallow of me to mention... but, do you have the cyrillic

    language set installed in your browser?

    Translate
    Nov 24, 2009 8:36 PM UTC

    haha, boy that would have been awesome! Yeah I do, anyways php pages pulling from the same tables display the cyrillic properly and natively (as in not unicode &#6332; etc)

    Translate
    Inspiring
    Nov 20, 2009 6:30 AM UTC

    what ver of cf? what ver of mysql?

    adding anything to the "ODBC connection string" isn't going to affect anything.

    you want to use the JDBC driver, never use ODBC if you want to use unicode.

    finally is the text data in the mysql database utf-8 to begin with? just because

    php can "pull them out properly" doesn't mean much.

    Translate
    Nov 21, 2009 6:27 PM UTC

    dev is apache 2.2.12 / CF 9 beta / MySQL 5

    production is IIS / CF 8 Enterprise / MySQL 5

    all tables are char set utf8 collate utf8_general_ci;

    Translate
    Inspiring
    Nov 22, 2009 3:03 AM UTC

    and the db driver? is there a public url i can see the issue?

    Translate