escpos_md/command/
charset.rs

1/// Possible character sets
2#[derive(Clone, Debug, Copy, PartialEq, Eq)]
3pub enum Charset {
4    /// United states of america
5    USA,
6    /// France
7    France,
8    /// Germany
9    Germany,
10    /// United Kingdom
11    UK,
12    /// 1st possibility for Denmark
13    Denmark1,
14    /// Sweden
15    Sweden,
16    /// Italy
17    Italy,
18    /// 1st possibility for Spain
19    Spain1,
20    /// Japan
21    Japan,
22    /// Norway
23    Norway,
24    /// 2nd possibility for Denmark
25    Denmark2,
26    /// 2nd possibility for Spain
27    Spain2,
28    /// Latin America
29    LatinAmerica,
30    /// Korea
31    Korea,
32    /// Slovenia or Croatia
33    SloveniaCroatia,
34    /// China
35    China,
36    /// Vietnam
37    Vietnam,
38    /// Arabia
39    Arabia,
40}
41
42impl Charset {
43    /// Returns the byte representation of the esc/pos command
44    pub fn as_bytes(&self) -> Vec<u8> {
45        match self {
46            Charset::USA => vec![0x00],
47            Charset::France => vec![0x01],
48            Charset::Germany => vec![0x02],
49            Charset::UK => vec![0x03],
50            Charset::Denmark1 => vec![0x04],
51            Charset::Sweden => vec![0x05],
52            Charset::Italy => vec![0x06],
53            Charset::Spain1 => vec![0x07],
54            Charset::Japan => vec![0x08],
55            Charset::Norway => vec![0x09],
56            Charset::Denmark2 => vec![0x0a],
57            Charset::Spain2 => vec![0x0b],
58            Charset::LatinAmerica => vec![0x0c],
59            Charset::Korea => vec![0x0d],
60            Charset::SloveniaCroatia => vec![0x0e],
61            Charset::China => vec![0x0f],
62            Charset::Vietnam => vec![0x10],
63            Charset::Arabia => vec![0x11],
64        }
65    }
66}