This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<head> | |
<link rel="stylesheet" type="text/css" href="//fonts.googleapis.com/css?family=Ubuntu+Mono" /> | |
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/tonsky/[email protected]/distr/fira_code.css"> | |
<style> | |
textarea { | |
font-family: Fira Code, monospace; | |
font-size: 12pt; | |
} | |
#measure { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
I've been thinking about file formats lately. When looking at different formats, it seems like there are common concepts used in many of them, the main ones being **textual data** and **hierarchy**. These concepts are usually implemented by stacking different encoding layers. For example, the SVG format can be seen as the following stack of abstractions: `SVG -> XML -> UTF-8 -> Binary`. In this case, the hierarchy is provided by XML and the encoding of textual data is done in XML and UTF-8. You might be wondering why textual data is handled both in XML and UTF-8. The reason for this is that one cannot simply paste a UTF-8-encoded string into an SVG file and expect it to work. A lot of strings would contain characters that have a meaning to the surrounding markup. The common solution to this is to use escape characters that indicate that the character following them should not be treated as markup. But other than that, textual data is encoded in UTF-8. | |
Having to handle textual data encoding at two levels in |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Panic context: | |
> | |
version: 796bfccac 2021-09-03 dev | |
request: codeLens/resolve CodeLens { | |
range: Range { | |
start: Position { | |
line: 0, | |
character: 3, | |
}, | |
end: Position { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::io::{self, Read}; | |
pub trait MyRead: Read { | |
#[inline(always)] | |
fn read_to_buf<const N: usize>(&mut self) -> io::Result<[u8; N]> { | |
let mut buf = [0; N]; | |
self.read_exact(&mut buf)?; | |
Ok(buf) | |
} | |
} |
OlderNewer