Exemplo n.º 1
0
func (c osx16Collator) Compare(a, b Input) int {
	sa := C.CFStringCreateWithCharactersNoCopy(
		nil,
		osxCharP(a.UTF16),
		C.CFIndex(len(a.UTF16)),
		nil,
	)
	sb := C.CFStringCreateWithCharactersNoCopy(
		nil,
		osxCharP(b.UTF16),
		C.CFIndex(len(b.UTF16)),
		nil,
	)
	_range := C.CFRangeMake(0, C.CFStringGetLength(sa))
	return int(C.CFStringCompareWithOptionsAndLocale(sa, sb, _range, c.opt, c.loc))
}
Exemplo n.º 2
0
func (c osx8Collator) Compare(a, b Input) int {
	sa := C.CFStringCreateWithBytesNoCopy(
		nil,
		osxUInt8P(a.UTF8),
		C.CFIndex(len(a.UTF8)),
		C.kCFStringEncodingUTF8,
		C.Boolean(0),
		nil,
	)
	sb := C.CFStringCreateWithBytesNoCopy(
		nil,
		osxUInt8P(b.UTF8),
		C.CFIndex(len(b.UTF8)),
		C.kCFStringEncodingUTF8,
		C.Boolean(0),
		nil,
	)
	_range := C.CFRangeMake(0, C.CFStringGetLength(sa))
	return int(C.CFStringCompareWithOptionsAndLocale(sa, sb, _range, c.opt, c.loc))
}