出现中文乱码,大概率就是编码问题导致的,使用GBK/GB2312进行编码
let printStr = "! 0 200 200 100 1\r\nPAGE-WIDTH 576\r\nUNDERLINE ON\r\nSETBOLD 0\r\nSETMAG 1 1\r\nTEXT 24 0 0 0 jdfkajdkjf你好jdfkajdkjf你好jdfkajdkjf你好\r\njdfkajdkjf你好jdfkajdkjf你好jdfkajdkjf你好jdfkajdkjf你好\r\njdfkajdkjf你好jdfkajdkjf你好jdfkajdkjf你好jdfkajdkjf你好\r\njdfkajdkjf你好jdfkajdkjf你好jdfkajdkjf你好jdfkajdkjf你好\r\njdfkajdkjf你好jdfkajdkjf你好jdfkajdkjf你好jdfkajdkjf你好jdfkajdkjf你好\r\nPRINT\n"
let enc = CFStringConvertEncodingToNSStringEncoding(UInt32(CFStringEncodings.GB_18030_2000.rawValue))
let strData = printStr.data(using: String.Encoding(rawValue: enc))