Home>Article>Database> How to solve the problem of mysql c garbled characters

How to solve the problem of mysql c garbled characters

藏色散人
藏色散人 Original
2021-12-06 14:28:34 1868browse

Mysql c garbled solution: 1. Find the my.cnf file and edit it to add "default-character-set=utf8"; 2. Add "mysql_set_character_set(&db,"utf8″);" to the program statement.

How to solve the problem of mysql c garbled characters

The operating environment of this article: Windows7 system, mysql5.5, DELL G3 computer

How to solve the problem of mysql c garbled characters?

C reading mysql produces garbled characters problem

When writing the interface API, I found that the Chinese characters utf8 input were read using c under Linux and displayed as "? ?" question mark, this is due to encoding.

It’s very simple to make changes in two places and it’s done.

1. First find the mysql my.cnf configuration file /etc/my.cnf, edit and add

[mysqld] default-character-set=utf8

2. Add the mysql_set_character_set(&db,”utf8″); statement in the program

Recommended learning: "mysql video tutorial"

The above is the detailed content of How to solve the problem of mysql c garbled characters. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn