signum/docs/cset.rs
1//! # (`cset`) The character set chunk
2
3use std::borrow::Cow;
4
5use nom::{
6 bytes::{complete::take_while, streaming::take},
7 multi::many0,
8 IResult,
9};
10
11/// Parse the `cset` chunk
12pub fn parse_cset(input: &[u8]) -> IResult<&[u8], Vec<Cow<str>>> {
13 many0(parse_cset_str)(input)
14}
15
16fn parse_cset_str(input: &[u8]) -> IResult<&[u8], Cow<str>> {
17 let (input, bytes) = take_while(|b| b > 0)(input)?;
18 let (input, _) = take(10 - bytes.len())(input)?;
19 Ok((input, String::from_utf8_lossy(bytes)))
20}