Skip to content

Commit 8ef724c

Browse files
committed
use ICU to define sorting
1 parent bc615c5 commit 8ef724c

File tree

3 files changed

+14
-14
lines changed

3 files changed

+14
-14
lines changed

NEWS.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# git2rdata 0.3.1
2+
3+
* Use `icuSetCollate()` to define a standardised sorting.
4+
15
# git2rdata 0.3.0
26

37
## New features
@@ -32,8 +36,8 @@
3236

3337
* Calculation of data hash has changed (#53).
3438
You must use `upgrade_data()` to read data stored by an older version.
35-
* `is_git2rdata()` and `upgrade_data()` do not test equality in data hashes
36-
anymore (but `read_vc()` still does).
39+
* `is_git2rdata()` and `upgrade_data()` no longer not test equality in data
40+
hashes (but `read_vc()` still does).
3741
* `write_vc()` and `read_vc()` fail when `file` is a location outside of `root`
3842
(#50).
3943
* Reordering factor levels requires `strict = TRUE`.

R/datahash.R

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -50,22 +50,18 @@ datahash <- function(file) {
5050
#' @noRd
5151
#' @return a named vector with the old locale
5252
set_c_locale <- function() {
53-
old_ctype <- Sys.getlocale(category = "LC_CTYPE")
54-
old_collate <- Sys.getlocale(category = "LC_COLLATE")
55-
old_time <- Sys.getlocale(category = "LC_TIME")
56-
Sys.setlocale(category = "LC_CTYPE", locale = "C")
57-
Sys.setlocale(category = "LC_COLLATE", locale = "C")
58-
Sys.setlocale(category = "LC_TIME", locale = "C")
59-
return(c(ctype = old_ctype, collate = old_collate, time = old_time))
53+
icuSetCollate(
54+
locale = "en_GB", case_first = "lower", normalization = "on",
55+
case_level = "on"
56+
)
57+
return(c())
6058
}
6159

6260
#' Reset the old locale
6361
#' @param locale the output of `set_c_locale()`
6462
#' @return invisible `NULL`
6563
#' @noRd
6664
set_local_locale <- function(locale) {
67-
Sys.setlocale(category = "LC_CTYPE", locale = locale["ctype"])
68-
Sys.setlocale(category = "LC_COLLATE", locale = locale["collate"])
69-
Sys.setlocale(category = "LC_TIME", locale = locale["time"])
65+
icuSetCollate(locale = "default")
7066
return(invisible(NULL))
7167
}

tests/testthat/test_b_special.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ expect_is(
1919
)
2020
expect_equal(
2121
names(output)[1],
22-
"9e5edf55ceadd2c148d6d715ea5d12cc8e1538d8"
22+
"1d135a85dc9beff3223d6c79f0d8975b559afca7"
2323
)
2424
old_locale <- git2rdata:::set_c_locale()
2525
dso <- ds[order(ds$a), , drop = FALSE] # nolint
@@ -64,7 +64,7 @@ expect_equal(
6464
)
6565
expect_equal(
6666
names(output)[1],
67-
"9e5edf55ceadd2c148d6d715ea5d12cc8e1538d8"
67+
"1d135a85dc9beff3223d6c79f0d8975b559afca7"
6868
)
6969
expect_identical(
7070
names(output),

0 commit comments

Comments
 (0)