[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: 8-bit char problem
From: |
Paul Kienzle |
Subject: |
Re: 8-bit char problem |
Date: |
Fri, 11 Oct 2002 14:41:27 -0400 |
> (AFAIK, abs was originally the recommended way to convert a string to
> ASCII in Matlab; maybe now they say to use double).
I think V5 they introduced char(), double(), etc.
> I'm open to suggestions for better things to do with out of range
> values other than converting to zero, but I'm afraid that anything
> else will not be easy.
>
> Matlab doesn't have this "problem" because character matrices are
> stored as arrays of double values with a special flag set, so setstr
> simply sets the flag and abs unsets it, which would preserve out of
> range values, except that it also checks for negative values and
> converts those to zero (with a warning). I'm not sure why they don't
> trap large values, since they don't seem too useful in strings. For
> example, I see this weird behavior:
>
> >> fprintf ('%s\n', setstr (100))
> d
> >> fprintf ('%s\n', setstr (400))
> 4.000000e+02
>
> Does this make any senes?
This makes sense if they are using unicode and require a 16-bit character
set. I believe they have patchy support for it in the most recent release.
>
> | Yes it will be painful because the system string functions and the
> | consumers of charMatrix use char, and we don't want to replace them all, so
> | casts will be sprinkled everywhere.
>
> Maybe there aren't that many places where it really matters.
I find it painful using casts for functions like strlen which really don't
care if the values are signed or unsigned, even if there aren't that many.
- Paul