MySQL Forums
Forum List  »  Connector/C++

Problem using Mysql++ query with utf8
Posted by: Joy Zhang
Date: January 21, 2009 04:42PM

I am using Mysql++ to access a DB where queries need to contain UTF8 characters.
Mysql server is running on Linux Fedora and the DB has been set with UTF8 collation.
I have tested the query using both php and running directly on phpmyadmin and it worked out fine.
However, using the C++ code listed below the DB always record the field in ASCII form as "Nürnberger".

I am really frustrated by this.
I have been google all day but it seems like no one has this problem before.
Is this a problem with mysql++ or something I did wrong?

Appreciate your help.

Joy

#include <iostream>
#include "stdio.h"
#include "stdlib.h"
#include <mysql++.h>
#include <iomanip>
#include <string>

using namespace std;

int main(int argc, char * argv[]){

// Connect to the sample database.
mysqlpp::Connection conn(false);
if (conn.connect("conversation","localhost","pandora","pandora")){
// Retrieve a subset of the sample stock table set up by resetdb
// and display it.

mysqlpp::Query query = conn.query();
query<<"insert into chinese_english (UserName) values ('Nürnberger')";
query.execute();

}
return 0;
}

Options: ReplyQuote


Subject
Views
Written By
Posted
Problem using Mysql++ query with utf8
7950
January 21, 2009 04:42PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.