fix(console): 🐛 Fix unicode character output
(At the expense of about 3kb code size.)
This commit is contained in:
parent
2c91e685bd
commit
1ca54d9ed6
|
@ -284,7 +284,11 @@ impl ConsoleOps for PreparedMiniUart {
|
||||||
if #[cfg(not(feature = "noserial"))] {
|
if #[cfg(not(feature = "noserial"))] {
|
||||||
/// Send a character
|
/// Send a character
|
||||||
fn write_char(&self, c: char) {
|
fn write_char(&self, c: char) {
|
||||||
self.write_byte(c as u8);
|
let mut b = [0u8; 4];
|
||||||
|
let _ = c.encode_utf8(&mut b);
|
||||||
|
for x in 0..c.len_utf8() {
|
||||||
|
self.write_byte(b[x]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Display a string
|
/// Display a string
|
||||||
|
@ -299,7 +303,7 @@ impl ConsoleOps for PreparedMiniUart {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Receive a character
|
/// Receive a character -- FIXME: needs a state machine to read UTF-8 chars!
|
||||||
fn read_char(&self) -> char {
|
fn read_char(&self) -> char {
|
||||||
let mut ret = self.read_byte() as char;
|
let mut ret = self.read_byte() as char;
|
||||||
|
|
||||||
|
|
|
@ -401,10 +401,15 @@ impl SerialOps for PreparedPL011Uart {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @todo Seems like a blanket implementation of ConsoleOps is in order..
|
||||||
impl ConsoleOps for PreparedPL011Uart {
|
impl ConsoleOps for PreparedPL011Uart {
|
||||||
/// Send a character
|
/// Send a character
|
||||||
fn write_char(&self, c: char) {
|
fn write_char(&self, c: char) {
|
||||||
self.write_byte(c as u8)
|
let mut b = [0u8; 4];
|
||||||
|
let _ = c.encode_utf8(&mut b);
|
||||||
|
for x in 0..c.len_utf8() {
|
||||||
|
self.write_byte(b[x]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Display a string
|
/// Display a string
|
||||||
|
@ -419,7 +424,7 @@ impl ConsoleOps for PreparedPL011Uart {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Receive a character
|
/// Receive a character -- FIXME: needs a state machine to read UTF-8 chars!
|
||||||
fn read_char(&self) -> char {
|
fn read_char(&self) -> char {
|
||||||
let mut ret = self.read_byte() as char;
|
let mut ret = self.read_byte() as char;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue