Re: GnomeICU Release



On 13 Jan 2001, Jeremy Wise wrote:

> Hi all,
>
>   I believe this is the address I'm supposed to send this to ;)  I'm
> about to release ICU 0.95 (great things have happened to it lately), and
> I figured I'd give you guys the heads up.  The code will be frozen now,
> so you should be safe editing the po files.  Also, I've been told that I
> need to do some work to make sure the country lists come out in
> alphabetical order AFTER they've been translated... imagine that...
> Anyway, if anyone has a quick hack to take care of that problem, I'll
> fix that up in the next release so you guys don't have to worry about it

I believe you could use "qsort" for sorting and "strcoll" for comparison.
Once Unicode comes into place, you will need to replace strcoll with the
Unicode counterpart.

Attached is a simple example of the above.

> again.  Thanks for all of your hard work!  Let me know when everything's
> ready to be tar balled up, and I'll get the releases made.
>
> Sincerely,
>
> Jeremy Wise
> GnomeICU Author
>
>



/*
 * CHANGES IN NOTATION
 * a. The last country should have code 0xffff
 *    We use this in order to count the coutries
 */

#include <stdlib.h>

typedef int WORD;

typedef struct
{
	  const char *name;
	    WORD code;
} COUNTRY_CODE;



static COUNTRY_CODE Country_Codes[] = {
  { "USA", 1 },
  { "Afghanistan", 93 },
  { "Albania", 355 },
  { "Algeria", 213 },
  { "American Samoa", 684 },
  { "We end here", 0xffff }
};

int count_country_entries( const COUNTRY_CODE *elements )
{
	register int counter;

	counter = 0;

	while ( elements[counter].code != 0xffff )
		counter++;

	return counter;
}

int compare_country_name( const void *element1, const void *element2 )
{
	COUNTRY_CODE *e1 = (COUNTRY_CODE *)element1;
	COUNTRY_CODE *e2 = (COUNTRY_CODE *)element2;
	
	return strcoll(e1->name, e2->name);
}

main()
{
	int i;
	
	qsort( Country_Codes, count_country_entries(Country_Codes), 
		sizeof(COUNTRY_CODE), compare_country_name);

	for ( i = 0; i < count_country_entries(Country_Codes); i++ )
	{
		printf("%s\n", Country_Codes[i].name);
	}

	return 0;
}



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]