[haiku-commits] Re: r41076 - haiku/trunk/src/kits/support

  • From: Ingo Weinhold <ingo_weinhold@xxxxxx>
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Tue, 22 Mar 2011 12:26:46 +0100

On 2011-03-22 at 11:37:54 [+0100], Clemens <clemens.zeidler@xxxxxxxxxxxxxx> 
wrote:
> On Tue, 22 Mar 2011 20:42:15 +1300, Jérôme Duval <korli@xxxxxxxxxxxxxxxx>
> wrote:
> 
> > 2011/3/22  <clemens.zeidler@xxxxxxxxxxxxxx>:
> >> Author: czeidler
> >> Date: 2011-03-22 04:05:39 +0100 (Tue, 22 Mar 2011)
> >> New Revision: 41076
> >> Changeset: https://dev.haiku-os.org/changeset/41076
> >> Ticket: https://dev.haiku-os.org/ticket/7392
> >>
> >> Modified:
> >>   haiku/trunk/src/kits/support/String.cpp
> >> Log:
> >> Fix Trim() method for empty strings and strings only containing spaces.
> >> Fixes #7392.
> >
> > I'm wondering why isspace() is used instead of iswspace(). Internal
> > representation is supposed to be UTF-8, which isspace() doesn't
> > handle, right?
> 
> think you are right but I'm not sure, if somebody else confirm it I will
> change it.

isspace() works fine on the ASCII range and ignores multibyte UTF-8 chars. 
Trim() was introduced in Haiku (and apparently not documented). We are free 
to define it's semantics. If Trim() is supposed to recognize non-ASCII 
whitespace, it would obviously have to iterate through UTF-8 chars. 
iswspace() is equivalent to isspace() when the current locale is 
"C"/"POSIX".

That aside, the end index loop is still broken (and inefficient).

CU, Ingo

Other related posts: