ID EN
Miscellaneous

icuSetCollate

R Base 3.6.2

Controls the way collation is done by ICU (an optional part of the R build).

Syntax

R
icuSetCollate(...)<p></p><p>icuGetCollate(type = c("actual", "valid"))</p>

Arguments

Parameter Description
&#8230; Named arguments, see ‘Details’.
type character string: can be abbreviated. Either the actual locale in use for collation or the most specific locale which would be valid.

Return Value

For icuGetCollate, a character string describing the ICU locale in use (which may be reported as "ICU not in use"). The ‘actual’ locale may be simpler than the requested locale: for example "da" rather than "da_DK": English locales are likely to report "root".

Details

Optionally, R can be built to collate character strings by ICU (http://site.icu-project.org). For such systems, icuSetCollate can be used to tune the way collation is done. On other builds calling this function does nothing, with a warning. Possible arguments are locale:A character string such as "da_DK" giving the language and country whose collation rules are to be used. If present, this should be the first argument. case_first:"upper", "lower" or "default", asking for upper- or lower-case characters to be sorted first. The default is usually lower-case first, but not in all languages (not under the default settings for Danish, for example). alternate_handling:Controls the handling of ‘variable’ characters (mainly punctuation and symbols). Possible values are "non_ignorable" (primary str

Examples

Example
R
# NOT RUN {
## These examples depend on having ICU available, and on the locale.
## As we don't know the current settings, we can only reset to the default.
if(capabilities("ICU")) {
    print(icuGetCollate())
    print(icuGetCollate("valid"))
    x <- c("Aarhus", "aarhus", "safe", "test", "Zoo")
    print(sort(x))
    icuSetCollate(case_first = "upper"); print(sort(x))
    icuSetCollate(case_first = "lower"); print(sort(x))

    ## Danish collates upper-case-first and with 'aa' as a single letter
    icuSetCollate(locale = "da_DK", case_first = "default"); print(sort(x))
    ## Estonian collates Z between S and T
    icuSetCollate(locale = "et_EE"); print(sort(x))
    icuSetCollate(locale = "default"); print(icuGetCollate("valid"))
}
# }

See Also

Comparison sort. capabilities for whether ICU is available; extSoftVersion for its version. The ICU user guide chapter on collation (http://userguide.icu-project.org/collation).