wu :: forums (http://www.ocf.berkeley.edu/~wwu/cgi-bin/yabb/YaBB.cgi)
riddles >> cs >> Locale aware memcmp function
(Message started by: Margit on Feb 7th, 2007, 9:53am)

Title: Locale aware memcmp function
Post by Margit on Feb 7th, 2007, 9:53am
As per subject.
How does one go about doing a memcmp
that is aware of the LC_COLLATE setting ?
Yes, I know there is strcoll, but the
things I am comparing have fixed widths
(not null-terminated) and may contain
null bytes.
It seems that there is no standard C library
function to do this.

Title: Re: Locale aware memcmp function
Post by towr on Feb 7th, 2007, 10:45am
What is LC_COLLATE?

Title: Re: Locale aware memcmp function
Post by Margit on Feb 7th, 2007, 11:39am
On 'nix systems -
man locale
man setlocale
man strcoll
man memmp

Title: Re: Locale aware memcmp function
Post by Margit on Feb 7th, 2007, 11:42am
Or if you are Win oriented -
http://msdn2.microsoft.com/zh-cn/library/x99tb11d(VS.80).aspx


Title: Re: Locale aware memcmp function
Post by Margit on Feb 7th, 2007, 11:45am
> What is LC_COLLATE?

Don't you know what how to sort ? :-)

Title: Re: Locale aware memcmp function
Post by TenaliRaman on Feb 7th, 2007, 10:24pm
How about this,
1. Copy the strcoll source to another function say "memcoll".
2. Remove the null termination condition from it.

-- AI

Title: Re: Locale aware memcmp function
Post by TenaliRaman on Feb 7th, 2007, 10:26pm
Well what do you know,
Google CodeSearch Memcoll (http://www.google.com/codesearch?hl=en&q=+memcoll+show:lW9UV4yhcDU:4InKAm9JMTs:47ThGO-4Aec&sa=N&cd=1&ct=rc&cs_p=http://gentoo.osuosl.org/distfiles/global-4.8.2.tar.gz&cs_f=global-4.8.2/gnusort/memcoll.c#a0)

Hail, google codesearch  ::)

-- AI

Title: Re: Locale aware memcmp function
Post by Margit on Feb 8th, 2007, 9:20am
That actually is busted and uses strcoll.
Other ideas ?



Powered by YaBB 1 Gold - SP 1.4!
Forum software copyright © 2000-2004 Yet another Bulletin Board