Skip to main content
November 19, 2009
Question

outputting cyrillic from mysql database

  • November 19, 2009
  • 3 replies
  • 1747 views

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 has been closed for replies.

    3 replies

    December 1, 2009

    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!

    Inspiring
    November 24, 2009

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

    language set installed in your browser?

    November 24, 2009

    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)

    Inspiring
    November 20, 2009

    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.

    November 21, 2009

    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;

    Inspiring
    November 22, 2009

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