Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6662993
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T02:27:02+00:00 2026-05-26T02:27:02+00:00

I have a mysql database, with two fields (firstname, lastname) of type CHAR(255) and

  • 0

I have a mysql database, with two fields (firstname, lastname) of type CHAR(255) and characterset utf_general_ci

Using mysqlphpadmin I set firstname to “Sàm” and lastname to “Èkméïß”
In my c code I retrieve these fields using:

sscanf(row[SDB_INV_COL_FIRSTNAME],"%[^\n]",db_firstname);
sscanf(row[SDB_INV_COL_LASTNAME],"%[^\n]",db_lastname);

But when I do so the db_firstname variable is set to ‘S\340m’
and db_lastname is set to ‘\310km\351\357\227’

It seems like the characters are being switched to unicode or some other characterset, and I can’t figure out how to correct this! How do I get my fields out as utf8 into my C variables?

My connection is setup like this (notice the charset setting):

conn = mysql_init(NULL);
if(conn == NULL) {
sprintf(tempstr,"Survey database connection init error: [%u] %s", mysql_errno(conn), mysql_error(conn));
logmessage(LLEVEL_ERROR, INTERROR_MYSQLCONNECT_FAILED, tempstr);
sdberrorstate = TRUE;
return FALSE;
}

if(!mysql_real_connect(conn, program_options.sdbhost , program_options.sdbusername , program_options.sdbpassword, program_options.sdbdatabase, program_options.sdbport, NULL, 0)) {
sprintf(tempstr,"Survey database real connection error [%u] [%s]", mysql_errno(conn), mysql_error(conn));
logmessage(LLEVEL_ERROR, INTERROR_MYSQLCONNECT_FAILED, tempstr);
sdberrorstate = TRUE;
return FALSE;
}

if(mysql_options(conn, MYSQL_SET_CHARSET_NAME, "utf8") != 0) {
sprintf(tempstr,"Survey database set characterset utf8 error [%u] [%s]", mysql_errno(conn), mysql_error(conn));
logmessage(LLEVEL_ERROR, INTERROR_MYSQLCONNECT_FAILED, tempstr);
sdberrorstate = TRUE;
return FALSE;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T02:27:03+00:00Added an answer on May 26, 2026 at 2:27 am

    You are receiving the data in ISO-8859-1. MySQL has encoding settings not only for the database tables, you should also set correctly the encoding to use for the MySQL client.

    Edit:

    From mysql_options() docs:

    mysql_options() should be called after mysql_init() and before mysql_connect() or mysql_real_connect()

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have 10 tables in my database(MySQL). two of them is given below tbl_state
I have a MySQL database. All the fields, I assign and I have a
I have a database with a singe table, and two fields in said table,
I would like to have a query using the schema database in MySQL that
I have two tables in my SQL database: mysql> select *from crop; +------+-----------+----------+ |
I have created two input fields using EditText, a TimePicker , a Spinner along
I have a MySQL database table with two columns that interest me. Individually they
I have a database that has two fields: current, and previous. Here is the
I have two physically-separate MySQL databases on which I have to run a single
When I have two mysql servers that have different jobs (holding different databases) but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.