This is a read-only copy of the MariaDB Knowledgebase generated on 2024-11-24. For the latest, interactive version please visit https://mariadb.com/kb/.

mysql_set_character_set

Syntax

int mysql_set_character_set(MYSQL * mysql,
                            const char * csname);

Description

Sets the default character set for the current connection. Returns zero on success, non-zero on failure.

It's strongly recommended to use mysql_set_character_set() instead of SET NAMES ... since mysql_real_escape_string() might fail or deliver unexpected results.

The client library supports the following character sets:

Character setDescription
armscii88 bit character set for Armenian
asciiUS ASCII character set
big52 byte character set for traditional Chinese, Hongkong, Macau and Taiwan
binary8 bit binary character set
cp1250Windows code page 1250 character set
cp1251Windows code page 1251 character set
cp1256Windows code page 1256 character set
cp1257Windows code page 1257 character set
cp850MS-DOS Codepage 850 (Western Europe)
cp852MS-DOS Codepage 852 (Middle Europe)
cp866MS-DOS Codepage 866 (Russian)
cp932Microsoft Codepage 932 (Extension to sjis)
dec8DEC West European
eucjpmsUJIS for Windows Japanese
euckrEUC KR-Korean
gb2312GB-2312 simplified Chinese
gbkGBK simplified Chinese
geostd8GEOSTD8 Georgian
greekISO 8859-7 Greek
hebrewISO 8859-8 Hebrew
hp8HP West European
keybcs2DOS Kamenicky Czech-Slovak
koi8rKOI8-R Relcom Russian
koi8uKOI8-U Ukrainian
latin1CP1252 Western European
latin2ISO 8859-2 Central Europe
latin5ISO 8859-9 Turkish
latin7ISO 8859-13 Baltic
macceMAC Central European
macromanMAC Western European
sjisSJIS for Windows Japanese
swe77-bit Swedish
tis620TIS620 Thai
ucs2UCS-2 Unicode
ujisEUC-JP Japanese
utf8UTF-8 Unicode
utf16UTF-16 Unicode
utf32UTF-32 Unicode
utf8mb4UTF 4-byte Unicode

See also

Content reproduced on this site is the property of its respective owners, and this content is not reviewed in advance by MariaDB. The views, information and opinions expressed by this content do not necessarily represent those of MariaDB or any other party.