MyDAC

National Characters

When data is transferred data between the client and server, the server needs to know the encoding used by the client. You can set the encoding by configuring the MySQL server settings (see the MySQL Reference Manual for details), or by using the TMyConnection.Options.Charset or TMyConnection.Options.UseUnicode properties on the client. The former way is less suitable as it requires access to the server settings, which is not always possible. The latter way is more convenient, but it may cause some delays.

The Charset and UseUnicode properties are mutually exclusive, thus when you set UseUnicode to True, the value of Charset is ignored. By default, Charset = '' and UseUnicode = False. The server makes conversions according to its settings.

If a character set is assigned to the Charset property, the SET NAMES <Charset> statement is passed to the server when establishing a connection, to notify it about the character used by the client. To get a list of available charsets, execute the SHOW CHARSET statement. Note that when you assign utf8 to this property, the values of all string fields are converted to UTF-8, which may prevent you from using data-aware components.

If you to need to receive string data in the Unicode format on the client to work with almost any language, or you connect with a username or password that contains characters like £, set the UseUnicode property to True. All TStringField values will be converted to TWideStringField. This behaviour is useful when, for example, you create a database of books in the library, and you need to store the original title of the book alongside the translated title. The downside is that all string data is converted on the client, which may cause some delays.

See Also

© 1997-2024 Devart. All Rights Reserved. Request Support DAC Forum Provide Feedback