1 // Copyright 2016 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
9 // Ideally these functions would be defined in a test file, but go test doesn't
10 // allow CGO in tests. The build tag should ensure either way that these
11 // functions will not end up in the package.
13 // TODO: Ensure that the correct ICU version is set.
16 #cgo LDFLAGS: -licui18n.57 -licuuc.57
18 #include <unicode/ustring.h>
19 #include <unicode/utypes.h>
20 #include <unicode/localpointer.h>
21 #include <unicode/ucasemap.h>
27 func doICU(tag, caser, input string) string {
28 err := C.UErrorCode(0)
30 cm := C.ucasemap_open(loc, C.uint32_t(0), &err)
32 buf := make([]byte, len(input)*4)
33 dst := (*C.char)(unsafe.Pointer(&buf[0]))
34 src := C.CString(input)
40 cn = C.ucasemap_utf8FoldCase(cm,
41 dst, C.int32_t(len(buf)),
42 src, C.int32_t(len(input)),
45 cn = C.ucasemap_utf8ToLower(cm,
46 dst, C.int32_t(len(buf)),
47 src, C.int32_t(len(input)),
50 cn = C.ucasemap_utf8ToUpper(cm,
51 dst, C.int32_t(len(buf)),
52 src, C.int32_t(len(input)),
55 cn = C.ucasemap_utf8ToTitle(cm,
56 dst, C.int32_t(len(buf)),
57 src, C.int32_t(len(input)),
60 return string(buf[:cn])