1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
use cratechar;
use CString;
unsafe extern "C"
/// This function bypasses the normal ICU data loading process and allows you to force ICU's system
/// data to come out of a user-specified area in memory.
///
/// ICU data must be at least 8-aligned, and should be 16-aligned. See
/// https://unicode-org.github.io/icu/userguide/icu_data/
///
/// The format of this data is that of the icu common data file, as is generated by the pkgdata
/// tool with mode=common or mode=dll. You can read in a whole common mode file and pass the
/// address to the start of the data, or (with the appropriate link options) pass in the pointer to
/// the data that has been loaded from a dll by the operating system, as shown in this code:
///
/// ```c++
/// extern const char U_IMPORT U_ICUDATA_ENTRY_POINT [];
/// // U_ICUDATA_ENTRY_POINT is same as entry point specified to pkgdata tool
/// UErrorCode status = U_ZERO_ERROR;
///
/// udata_setCommonData(&U_ICUDATA_ENTRY_POINT, &status);
/// ```
///
/// It is important that the declaration be as above. The entry point must not be declared as an
/// extern void*.
///
/// Starting with ICU 4.4, it is possible to set several data packages, one per call to this
/// function. udata_open() will look for data in the multiple data packages in the order in which
/// they were set. The position of the linked-in or default-name ICU .data package in the search
/// list depends on when the first data item is loaded that is not contained in the already
/// explicitly set packages. If data was loaded implicitly before the first call to this function
/// (for example, via opening a converter, constructing a UnicodeString from default-codepage data,
/// using formatting or collation APIs, etc.), then the default data will be first in the list.
///
/// This function has no effect on application (non ICU) data. See udata_setAppData() for similar
/// functionality for application data.
// TODO(ry) Map error code to something useful.
/// Returns BCP47 language tag.
/// Returns the id of ICU's current default time zone, usually an IANA id such
/// as `"America/New_York"`. It can also be a custom offset id like
/// `"GMT+05:00"`, either because one was installed with
/// [`set_default_time_zone`] or because the host reported its zone that way,
/// so don't assume the result resolves against the tz database.
///
/// If the host time zone could not be determined, ICU reports the special
/// id `"Etc/Unknown"`, which behaves as GMT.
/// Sets ICU's default time zone from a time zone id (e.g. `"UTC"`,
/// `"Asia/Manila"`). This makes `Date` resolve the given zone on every
/// platform, including Windows, where ICU otherwise reads the host time
/// zone from the OS and ignores the `TZ` environment variable.
///
/// Returns `false` — leaving the current default untouched — if `time_zone_id`
/// is not a time zone id ICU recognizes. Note that ICU's own "unknown zone"
/// id, `"Etc/Unknown"`, is rejected as well. Besides IANA ids, ICU accepts
/// custom offset ids such as `"GMT+05:00"`.
///
/// This mutates process wide state and is not synchronized with isolates
/// running on other threads, so it should be called before those isolates
/// evaluate any code observing the time zone. Afterwards, notify each isolate
/// via [`crate::Isolate::date_time_configuration_change_notification`] with
/// [`crate::TimeZoneDetection::Skip`] so cached values are refreshed without
/// re-detecting (and overwriting) the zone just set here.