Rechercher dans le manuel MySQL
10.12 Adding a Character Set
[+/-]
This section discusses the procedure for adding a character set to MySQL. The proper procedure depends on whether the character set is simple or complex:
If the character set does not need special string collating routines for sorting and does not need multibyte character support, it is simple.
If the character set needs either of those features, it is complex.
For example, greek and swe7
are simple character sets, whereas big5 and
czech are complex character sets.
To use the following instructions, you must have a MySQL source
distribution. In the instructions,
MYSET represents the name of the
character set that you want to add.
Add a
<charset>element forMYSETto thesql/share/charsets/Index.xmlfile. Use the existing contents in the file as a guide to adding new contents. A partial listing for thelatin1<charset>element follows:<charset name="latin1"> <family>Western</family> <description>cp1252 West European</description> ... <collation name="latin1_swedish_ci" id="8" order="Finnish, Swedish"> <flag>primary</flag> <flag>compiled</flag> </collation> <collation name="latin1_danish_ci" id="15" order="Danish"/> ... <collation name="latin1_bin" id="47" order="Binary"> <flag>binary</flag> <flag>compiled</flag> </collation> ... </charset>The
<charset>element must list all the collations for the character set. These must include at least a binary collation and a default (primary) collation. The default collation is often named using a suffix ofgeneral_ci(general, case insensitive). It is possible for the binary collation to be the default collation, but usually they are different. The default collation should have aprimaryflag. The binary collation should have abinaryflag.You must assign a unique ID number to each collation. The range of IDs from 1024 to 2047 is reserved for user-defined collations. To find the maximum of the currently used collation IDs, use this query:
This step depends on whether you are adding a simple or complex character set. A simple character set requires only a configuration file, whereas a complex character set requires C source file that defines collation functions, multibyte functions, or both.
For a simple character set, create a configuration file,
, that describes the character set properties. Create this file in theMYSET.xmlsql/share/charsetsdirectory. You can use a copy oflatin1.xmlas the basis for this file. The syntax for the file is very simple:Comments are written as ordinary XML comments (
<!--).text-->Words within
<map>array elements are separated by arbitrary amounts of whitespace.Each word within
<map>array elements must be a number in hexadecimal format.The
<map>array element for the<ctype>element has 257 words. The other<map>array elements after that have 256 words. See Section 10.12.1, “Character Definition Arrays”.For each collation listed in the
<charset>element for the character set inIndex.xml,must contain aMYSET.xml<collation>element that defines the character ordering.
For a complex character set, create a C source file that describes the character set properties and defines the support routines necessary to properly perform operations on the character set:
Create the file
ctype-in theMYSET.cstringsdirectory. Look at one of the existingctype-*.cfiles (such asctype-big5.c) to see what needs to be defined. The arrays in your file must have names likectype_,MYSETto_lower_, and so on. These correspond to the arrays for a simple character set. See Section 10.12.1, “Character Definition Arrays”.MYSETFor each
<collation>element listed in the<charset>element for the character set inIndex.xml, thectype-file must provide an implementation of the collation.MYSET.cIf the character set requires string collating functions, see Section 10.12.2, “String Collating Support for Complex Character Sets”.
If the character set requires multibyte character support, see Section 10.12.3, “Multi-Byte Character Support for Complex Character Sets”.
Modify the configuration information. Use the existing configuration information as a guide to adding information for
MYSYS. The example here assumes that the character set has default and binary collations, but more lines are needed ifMYSEThas additional collations.Edit
mysys/charset-def.c, and “register” the collations for the new character set.Add these lines to the “declaration” section:
#ifdef HAVE_CHARSET_MYSET extern CHARSET_INFO my_charset_MYSET_general_ci; extern CHARSET_INFO my_charset_MYSET_bin; #endifAdd these lines to the “registration” section:
#ifdef HAVE_CHARSET_MYSET add_compiled_collation(&my_charset_MYSET_general_ci); add_compiled_collation(&my_charset_MYSET_bin); #endifIf the character set uses
ctype-, editMYSET.cstrings/CMakeLists.txtand addctype-to the definition of theMYSET.cSTRINGS_SOURCESvariable.Edit
cmake/character_sets.cmake:Add
MYSETto the value of withCHARSETS_AVAILABLEin alphabetic order.Add
MYSETto the value ofCHARSETS_COMPLEXin alphabetic order. This is needed even for simple character sets, or CMake will not recognize-DDEFAULT_CHARSET=.MYSET
Reconfigure, recompile, and test.
Deutsche Übersetzung
Sie haben gebeten, diese Seite auf Deutsch zu besuchen. Momentan ist nur die Oberfläche übersetzt, aber noch nicht der gesamte Inhalt.Wenn Sie mir bei Übersetzungen helfen wollen, ist Ihr Beitrag willkommen. Alles, was Sie tun müssen, ist, sich auf der Website zu registrieren und mir eine Nachricht zu schicken, in der Sie gebeten werden, Sie der Gruppe der Übersetzer hinzuzufügen, die Ihnen die Möglichkeit gibt, die gewünschten Seiten zu übersetzen. Ein Link am Ende jeder übersetzten Seite zeigt an, dass Sie der Übersetzer sind und einen Link zu Ihrem Profil haben.
Vielen Dank im Voraus.
Dokument erstellt 26/06/2006, zuletzt geändert 26/10/2018
Quelle des gedruckten Dokuments:https://www.gaudry.be/de/mysql-rf-adding-character-set.html
Die Infobro ist eine persönliche Seite, deren Inhalt in meiner alleinigen Verantwortung liegt. Der Text ist unter der CreativeCommons-Lizenz (BY-NC-SA) verfügbar. Weitere Informationen auf die Nutzungsbedingungen und dem Autor.
Referenzen
Diese Verweise und Links verweisen auf Dokumente, die während des Schreibens dieser Seite konsultiert wurden, oder die zusätzliche Informationen liefern können, aber die Autoren dieser Quellen können nicht für den Inhalt dieser Seite verantwortlich gemacht werden.
Der Autor dieser Website ist allein dafür verantwortlich, wie die verschiedenen Konzepte und Freiheiten, die mit den Nachschlagewerken gemacht werden, hier dargestellt werden. Denken Sie daran, dass Sie mehrere Quellinformationen austauschen müssen, um das Risiko von Fehlern zu reduzieren.