Re: Status of UTF-8 support in 0.83 dev
"ZIGLIO, Frediano, VF-IT" <[email protected]>
| Newsgroups | gmane.comp.db.tds.freetds |
|---|---|
| Message-ID | <[email protected]> |
> > Frediano, > > I am not sure to get what you mean by: > > > I think that column size == count in bytes is required cause: > > Do you mean the ColumnSize parameter of SQLBindColumn() > should be provided as a number of bytes instead of characters? > I am not sure this is a good idea, as it is used to define > the SQL type (NVARCHAR(ColumnSize)) ... > I mean, SQL Native Client expect a number of characters, not bytes. > > FYI: Not sure this helps: > > If you want to known the maximum number of bytes a multi-byte > character can use in the current locale, > you have the standard MB_CUR_MAX macro... (man MB_CUR_MAX). > > Thanks for your great help. > Seb > Mmm.... well... try to execute this query DECLARE @n INT DECLARE @single VARCHAR(10) DECLARE @bin VARBINARY(10) DECLARE @c_in NVARCHAR(10) DECLARE @c_out NVARCHAR(10) SET @n = 8200 WHILE @n <= 8300 BEGIN SET @c_in = CONVERT(NVARCHAR(10), NCHAR(@n)) SET @bin = CONVERT(VARBINARY(10), CONVERT(VARCHAR(10), @c_in COLLATE Chinese_PRC_CI_AI_KS_WS) COLLATE Chinese_PRC_CI_AI_KS_WS) SET @single = CONVERT(VARCHAR(10), @c_in COLLATE Chinese_PRC_CI_AI_KS_WS) COLLATE Chinese_PRC_CI_AI_KS_WS SET @c_out = CONVERT(NVARCHAR(10), @single COLLATE Chinese_PRC_CI_AI_KS_WS) COLLATE Chinese_PRC_CI_AI_KS_WS IF @c_in <> @c_out AND @c_out <> '?' AND DATALENGTH(@bin) > 1 SELECT @n, '-' + CONVERT(VARCHAR(1), @c_in COLLATE Chinese_PRC_CI_AI_KS_WS) COLLATE Chinese_PRC_CI_AI_KS_WS + '-', '-' + CONVERT(VARCHAR(2), @c_in COLLATE Chinese_PRC_CI_AI_KS_WS) COLLATE Chinese_PRC_CI_AI_KS_WS + '-' SET @n = @n + 1 END what do you think about? :) As you can see in VARCHAR(n) n is not the character size but the byte size :) Strange, isn't it? So NVARCHAR(n) is n*2 bytes long... in recent days it seems that MS silently convert wide from UCS2 (always 2 byte for a characters) into UTF16 (2 or 4 bytes per characters) so we cannot day anymore that NVARCHAR(n) is n characters long but we can always say that is 2*n bytes long.... yes, welcome to our nigthmare !!! freddy77 _______________________________________________ FreeTDS mailing list [email protected] http://lists.ibiblio.org/mailman/listinfo/freetds
smime.p7s
(application/x-pkcs7-signature, 3.1 KB) - not displayed