Skip to Content.
Sympa Menu

freetds - Re: [freetds] hex(92), freeTDS and MS SQL

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: Lapo Luchini <lapo AT lapo.it>
  • To: freetds AT lists.ibiblio.org
  • Subject: Re: [freetds] hex(92), freeTDS and MS SQL
  • Date: Mon, 18 Dec 2006 21:43:40 +0000 (UTC)

Daniel Fazekas <fdsubs <at> axelero.hu> writes:
> > however, when someone pastes a "smart-quoted" quotation mark from
> > word (hex92) into a field to put it into the database, it gets changed
> > into a question mark (hex63).
>
> Try changing your client charset setting in freetds.conf to
> windows-1252.
>
> iso-8859-1 doesn't contain the "smart quotes."

I noticed that the server encoding can't be changed, and for char/text fields
ISO-8859-1 is used.
As noted ISO-8859-1 doesn't have quotes at 0x92.

But how changing the client encoding to CP1252 could solve the problem?
The server CP1252 would be transformed from ISO-8859-1 (while it is not!) to
CP1252, and a conversion error would be there anyway, as ISO-8859-1 doesn't
have
where it is the source of a conversion to UTF-8 or to CP1252: it is the source
of the conversion that it is wrong, not the destination.

Maybe I'm completely wrnog, but it seems to me that the "correct" thing to do
is
to use CP1252 as the *server* encoding, for single-byte fields: SQLServer may
well state to use "iso_1" but, well, it is simply not true...

Works for me (even with client charset = utf-8, as it now does the right
think:
CP1252 => UTF-8, instead of the wrong ISO-8859-1 => UTf-8):

--- src/tds/iconv.c.orig Wed Mar 30 02:35:18 2005
+++ src/tds/iconv.c Mon Dec 18 22:35:49 2006
@@ -96,15 +96,15 @@
iconv_t cd;

/* first entries should be constants */
- assert(strcmp(canonic_charsets[POS_ISO1].name, "ISO-8859-1") == 0);
+// assert(strcmp(canonic_charsets[POS_ISO1].name, "ISO-8859-1") == 0);
assert(strcmp(canonic_charsets[POS_UTF8].name, "UTF-8") == 0);
assert(strcmp(canonic_charsets[POS_UCS2LE].name, "UCS-2LE") == 0);
assert(strcmp(canonic_charsets[POS_UCS2BE].name, "UCS-2BE") == 0);

/* fast tests for GNU-iconv */
- cd = tds_sys_iconv_open("ISO-8859-1", "UTF-8");
+ cd = tds_sys_iconv_open("WINDOWS-1252", "UTF-8");
if (cd != (iconv_t) - 1) {
- iconv_names[POS_ISO1] = "ISO-8859-1";
+ iconv_names[POS_ISO1] = "WINDOWS-1252";
iconv_names[POS_UTF8] = "UTF-8";
tds_sys_iconv_close(cd);
} else {
@@ -339,7 +339,7 @@

#if !HAVE_ICONV_ALWAYS

- strcpy(client->name, "ISO-8859-1");
+ strcpy(client->name, "WINDOWS-1252");
strcpy(server->name, UCS_2LE);

bytes_per_char(client);
@@ -394,11 +394,11 @@
*/
name = UCS_2LE;
if (tds->major_version < 7) {
- name = "ISO-8859-1";
+ name = "WINDOWs-1252";
if (tds->env && tds->env->charset)
name = tds->env->charset;
}
- fOK = tds_iconv_info_init(tds->char_convs[iso2server_metadata],
"ISO-885
9-1", name);
+ fOK = tds_iconv_info_init(tds->char_convs[iso2server_metadata],
"WINDOWs
-1252", name);

#endif
}
@@ -997,7 +997,7 @@

tds_iconv_info_close(char_conv);

- tds_iconv_info_init(char_conv, "ISO-8859-1", charset);
+ tds_iconv_info_init(char_conv, "WINDOWS-1252", charset);
#endif
}







Archive powered by MHonArc 2.6.24.

Top of Page