-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathChangeInternationalEncoding.swift
51 lines (46 loc) · 1.65 KB
/
ChangeInternationalEncoding.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
//
// ChangeInternationalEncoding.swift
//
//
// Created by chen on 2023/11/11.
//
import Foundation
/// The ^CI command enables you to call up the international character set you want to use for printing. You can mix character sets on a label.
///
/// # Change International Font/Encoding
///
/// Zebra printers can print fonts using international character sets: U.S.A.1, U.S.A.2, UK, Holland,
/// Denmark/ Norway, Sweden/Finland, Germany, France 1, France 2, Italy, Spain, and several other sets,
/// including the Unicode character set.
///
/// A character within a font can be remapped to a different numerical position.
///
/// - Remark: In x.14 version of firmware and later,
/// this command allows character remapping when parameter a = 0-13.
public struct ChangeInternationalEncoding: ZPLCommandConvertible {
public typealias Remap = (source: UInt8, destination: UInt8)
/// Desired character set
public var characterSet: UInt8
public var remapping: [Remap]
public var command: String {
"^CI\(characterSet)" +
remapping.map { ",\($0),\($1)" }.joined()
}
/// Change International Font/Encoding
///
/// - Parameters:
/// - characterSet: Desired character set
/// - remapping: Remapping sources and destinations.
public init(characterSet: UInt8, remapping: Remap...) {
self.characterSet = characterSet
self.remapping = remapping
}
/// Change International Font/Encoding
///
/// - Parameters:
/// - characterSet: Desired character set
public init(characterSet: UInt8) {
self.characterSet = characterSet
self.remapping = []
}
}