Closed hoanhtdd closed 2 months ago
@hoanhtdd You need to enable Double-Byte characters to print Japanese. You can do this using the Star Quick Setup Utility; you can get it from the App Store.
Here's a brief guide to make this change
From here, try to re-print the receipt and it should work 🤞
@hoanhtddBạn cần bật ký tự Double-Byte để in tiếng Nhật. Bạn có thể làm điều này bằng Star Quick Setup Utility; bạn có thể lấy nó từ App Store .
Dưới đây là hướng dẫn ngắn gọn để thực hiện thay đổi này
- Chọn máy in của bạn
- Chuyển đến Cài đặt máy in -> Cài đặt chuyển đổi bộ nhớ
- Thay đổi bộ ký tự thành Multi Byte
- Thay đổi bộ phông chữ MBCS sang tiếng Nhật
- Nhấp vào nút Áp dụng để lưu cài đặt vào máy in của bạn
Từ đây, hãy thử in lại biên lai và nó sẽ hoạt động 🤞
I'm using the printer's ios sdk, is there any way
I've been looking for places where I can set Japanese in the code, but it still doesn't work
.styleInternationalCharacter(.japan) .styleSecondPriorityCharacterEncoding(StarXpandCommand.Printer.CharacterEncodingType.japanese) .styleCJKCharacterPriority([StarXpandCommand.Printer.CJKCharacterType.japanese])
@hoanhtdd this needs to be done twice. This needs to be done in code to ensure the text is properly encoded. It also needs to be done as a printer setting to ensure the printer knows to expect double-byte Japanese characters.
Without both steps, you'll have an encoding mismatch similar to your current result.
@hoanhtdd any luck?
I followed your instructions, when I open the Star Quick Setup Utility app, I see the default parameters as shown in the picture
@hoanhtdd Is the problem solved? I changed the sample code to the following.
//
// PrintingViewController.swift
// StarXpandSDK
//
// Copyright © 2021 Star Micronics. All rights reserved.
//
import UIKit
import StarIO10
class PrintingViewController: UIViewController {
@IBOutlet weak var interfaceSelector: UISegmentedControl!
@IBOutlet weak var identifierTextField: UITextField!
@IBOutlet weak var printButton: UIButton!
override func viewDidLoad() {
super.viewDidLoad()
}
@IBAction func touchUpPrintButton(_ sender: Any) {
let identifier = identifierTextField.text ?? ""
var selectedInterface: InterfaceType = InterfaceType.unknown
switch interfaceSelector.selectedSegmentIndex {
case 0:
selectedInterface = InterfaceType.lan
case 1:
selectedInterface = InterfaceType.bluetooth
case 2:
selectedInterface = InterfaceType.bluetoothLE
case 3:
selectedInterface = InterfaceType.usb
default:
return
}
let starConnectionSettings = StarConnectionSettings(interfaceType: selectedInterface,
identifier: identifier)
let printer = StarPrinter(starConnectionSettings)
guard let logo = UIImage(named: "logo_01") else {
print("Failed to load \"logo_01.png\".")
return
}
// TSP100III series does not support actionPrintText because these products are graphics-only printers.
// Please use the actionPrintImage method to create printing data for these products.
// For other available methods, please also refer to "Supported Model" of each method.
// https://star-m.jp/products/s_print/sdk/starxpand/manual/en/ios-swift-api-reference/star-xpand-command/printer-builder/action-print-image.html
let builder = StarXpandCommand.StarXpandCommandBuilder()
_ = builder.addDocument(StarXpandCommand.DocumentBuilder()
// To open a cash drawer, comment out the following code.
// .addDrawer(StarXpandCommand.DrawerBuilder()
// .actionOpen(StarXpandCommand.Drawer.OpenParameter())
// )
.addPrinter(StarXpandCommand.PrinterBuilder()
.actionPrintText("アボカドアボカドアボ\n" +
"\n" +
"\n" +
"\n")
.actionCut(StarXpandCommand.Printer.CutType.partial)
)
)
let command = builder.getCommands()
Task {
do {
try await printer.open()
defer {
Task {
await printer.close()
}
}
try await printer.print(command: command)
print("Success")
} catch let error {
print("Error: \(error)")
}
}
}
}
Printer settings: the same as your settings
Printing result:
If you haven't solved the problem, could you please try this sample?
i have problem again with this text on mc_print3 :'アボカドアボカドアボ' , it doesn't print as i want but the text below prints correctly