MyDAC

National Characters

On transferring data between client and server sides, server must know the encoding format used at the client. You can set the coding using server means by assigning corresponding parameters at the server settings (see MySQL Reference Manual for details), or by client methods setting TCustomMyConnection.Options.Charset or TCustomMyConnection.Options.UseUnicode properties. The first way is less suitable as it requires meddling in server settings that is not always possible. The second way is more convenient but it can cause insignificant delay while establishing a connection.

Let us see the specific of using Charset and UseUnicode options. These options are mutually exclusive, thus on setting UseUnicode property to True a value of Charset will be ignored.

By default, Charset = '', and UseUnicode = False. And the server makes conversions according to its settings.

If Charset property is enabled, then on establishing a connection "SET NAMES <Charset>" query is automatically passed to the server to explicitly notify the server about the character set of the client. To get a list of available charsets, you can execute "SHOW CHARSET" query. Pay attention that on setting Charset = 'utf8' values of all string fields will be converted to this encoding format that in most cases can make impossible to use DataAware components.

Setting UseUnicode property to True allows to retrieve string data at the client side in Unicode encoding format that let you work simultaneously almost with all languages. All TStringField values will be converted to TWideStringField. This behaviour is suitable, for example, when creating a database of books in the library, when next to the name of a book you should also store its name in the original language. Please note that setting this option has some imperfections. Such as that all string data at the client side will be converted, and it can cause a delay in working.

See Also

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