Skip to Content.
Sympa Menu

freetds - Re: Ode to UTF-8 (fwd)

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: "James K. Lowden" <jklowden AT speakeasy.net>
  • To: freetds AT franklin.metalab.unc.edu
  • Subject: Re: Ode to UTF-8 (fwd)
  • Date: Tue, 3 Sep 2002 06:36:01 -0700


Date: Tue, 3 Sep 2002 06:20:19 -0700
From: James K. Lowden <jklowden AT speakeasy.net>

On 02 Sep 2002, Brian Bruns wrote:
> > That means making FreeTDS capable of passing
> > UCS-2 (or even UCS-4, for that matter). I
> > was going to try to avoid that, but I was
> > wrong. :) In so doing, there's one thing I
> > would like us to avoid: Any "if Unicode X
> > else Y" sort of code. I'm pretty sure you
> > agree with me on that point. As data are
> > plucked off the wire, the byte and character
> > counts should be set. After that, there's no
> > reason to re-examine the encoding.
>
> There are two basic places where we care about
> unicode vs. none.
>
> The first is int tds_get_string(). While this
> is dependant on the protocol version and not
> on column type there is a branch here.

In working on the UG, the question arose: What would be the effect of
setting the client character set to UTF-8 when the protocol is 4.2 or 5.0? I
think currently we use iconv only to "step down" the data from UCS-2, but it
would be helpful to our Mac friends if we could step it up, too.

> Secondly, if we are going to support
> character sets in which 0-9 and . are not in
> their ascii positions the convert code will
> have to know whether to call iconv or not. I
> don't see anyway around this....open to
> suggestions though.

I've been dissuading people from testing against 30 when they mean '0' based
on mesozoic habits of portability.

Assertion: Every character set iconv can deal with has the digits '0'..'9' in
sequential order. Same goes for 'A'..'F'. (I bet everyone the world over
writes hex the same way.) The only exception I've ever seen is EBCDIC IIRC,
and on the iconv FAQ the EBCDIC question has a one-word answer, "No!"

I think the most portable way to write atoi() -- for any value of 'a' ;) --
is to first query iconv for the character set's values for '0' and '9'. Then
comparisons can be made against those answers safely e.g., "if (zero <= s[i]
&& s[i] <= nine)".

Regards,

--jkl






Archive powered by MHonArc 2.6.24.

Top of Page