source/AccessorySDK/Support/utfconv.c
static void
priortysort(uint16_t* characters, int count)
{
	uint32_t p1, p2;
	uint16_t *ch1, *ch2;
	uint16_t *end;
	int changes;
	uint16_t tmp, tmp2;

	end = characters + count;
	do {
		changes = 0;
		ch1 = characters;
		ch2 = characters + 1;
		tmp = ReadHost16(ch1);
		p2 = get_combining_class(tmp);
		while (ch2 < end) {
			p1 = p2;
			tmp = ReadHost16(ch2);
			p2 = get_combining_class(tmp);
			if (p1 > p2 && p2 != 0) {
				tmp  = ReadHost16(ch1);
				tmp2 = ReadHost16(ch2);
				WriteHost16(ch1, tmp2);
				WriteHost16(ch2, tmp);
				changes = 1;
				
				/*
				 * Make sure that p2 contains the combining class for the
				 * character now stored at *ch2.  This isn't required for
				 * correctness, but it will be more efficient if a character
				 * with a large combining class has to "bubble past" several
				 * characters with lower combining classes.
				 */
				p2 = p1;
			}
			++ch1;
			++ch2;
		}
	} while (changes);
}
/*
 * priortysort - order combining chars into canonical order
 *
 * Similar to CFUniCharPrioritySort
 */
order combining chars into canonical order
Similar to CFUniCharPrioritySort
order combining chars into canonical order Similar to CFUniCharPrioritySort
static void
priortysort(uint16_t* characters, int count)
{
	uint32_t p1, p2;
	uint16_t *ch1, *ch2;
	uint16_t *end;
	int changes;
	uint16_t tmp, tmp2;
	end = characters + count;
	do {
		changes = 0;
		ch1 = characters;
		ch2 = characters + 1;
		tmp = ReadHost16(ch1);
		p2 = get_combining_class(tmp);
		while (ch2 < end) {
			p1 = p2;
			tmp = ReadHost16(ch2);
			p2 = get_combining_class(tmp);
			if (p1 > p2 && p2 != 0) {
				tmp  = ReadHost16(ch1);
				tmp2 = ReadHost16(ch2);
				WriteHost16(ch1, tmp2);
				WriteHost16(ch2, tmp);
				changes = 1;
				p2 = p1;
			}
			++ch1;
			++ch2;
		}
	} while (changes);
}
static void priortysort ( uint16_t * characters , int count ) { uint32_t p1 , p2 ; uint16_t * ch1 , * ch2 ; uint16_t * end ; int changes ; uint16_t tmp , tmp2 ; end = characters + count ; do { changes = 0 ; ch1 = characters ; ch2 = characters + 1 ; tmp = ReadHost16 ( ch1 ) ; p2 = get_combining_class ( tmp ) ; while ( ch2 < end ) { p1 = p2 ; tmp = ReadHost16 ( ch2 ) ; p2 = get_combining_class ( tmp ) ; if ( p1 > p2 && p2 != 0 ) { tmp = ReadHost16 ( ch1 ) ; tmp2 = ReadHost16 ( ch2 ) ; WriteHost16 ( ch1 , tmp2 ) ; WriteHost16 ( ch2 , tmp ) ; changes = 1 ; p2 = p1 ; } ++ ch1 ; ++ ch2 ; } } while ( changes ) ; }
priortysort - order combining chars into canonical order
 Similar to CFUniCharPrioritySort
priortysort - order combining chars into canonical order Similar to CFUniCharPrioritySort
/*
				 * Make sure that p2 contains the combining class for the
				 * character now stored at *ch2.  This isn't required for
				 * correctness, but it will be more efficient if a character
				 * with a large combining class has to "bubble past" several
				 * characters with lower combining classes.
				 */