Skip to content

Commit 7f0a00a

Browse files
uefi-raw: Add Char8/Char16
These definitions are just type aliases, unlike the more restrictive newtypes in the `uefi` package. In particular, the `uefi` package does not allow `Char16` to be created for surrogate pair characters. This is more restrictive than what UEFI actually specifies though; it says that `Char16` is _usually_ UCS-2, but particular uses may allow other encodings. So for `uefi-raw`, just treat `Char16` as numbers that can hold any `u16` value.
1 parent 86e4a01 commit 7f0a00a

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

uefi-raw/src/lib.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,21 @@ mod status;
2525
pub use status::Status;
2626
pub use uguid::{guid, Guid};
2727

28+
/// One-byte character.
29+
///
30+
/// Most strings in UEFI use [`Char16`], but a few places use one-byte
31+
/// characters. Unless otherwise noted, these are encoded as 8-bit ASCII using
32+
/// the ISO-Latin-1 character set.
33+
pub type Char8 = u8;
34+
35+
/// Two-byte character.
36+
///
37+
/// Unless otherwise noted, the encoding is UCS-2. The UCS-2 encoding was
38+
/// defined by Unicode 2.1 and ISO/IEC 10646 standards, but is no longer part of
39+
/// the modern Unicode standards. It is essentially UTF-16 without support for
40+
/// surrogate pairs.
41+
pub type Char16 = u16;
42+
2843
/// Physical memory address. This is always a 64-bit value, regardless
2944
/// of target platform.
3045
pub type PhysicalAddress = u64;

0 commit comments

Comments
 (0)