纯 MoonBit 原生的一维条码(1D barcode)生成、校验与渲染工具库:EAN-13 / EAN-8 / UPC-A / Code 39 / Code 93 / Code 128 / ITF-14 编码、ISBN / ISSN / GTIN 校验、SVG / ASCII / ANSI 渲染,可编译为 native / wasm / wasm-gc / js 多后端。
Dependencies
# 编码为 SVG 文件
moon run cmd/main -- encode --type ean13 --data 6901234567892 --out out.svg
# 终端 ASCII 预览
moon run cmd/main -- encode --type ean13 --data 6901234567892 --format ascii
# 校验 ISBN-13
moon run cmd/main -- validate --type isbn13 --data 978-0-306-40615-7let barcode = @moonbarcode.encode(@moonbarcode.EAN13, "6901234567892")pub struct BarcodeOptions {
module_width : Int
height : Int
quiet_zone : Int
show_text : Bool
text_margin : Int
}fn BarcodeOptions::new(module_width? : Int, height? : Int, quiet_zone? : Int, show_text? : Bool, text_margin? : Int) -> BarcodeOptionsfn code128_checksum(data : String, gs1? : Bool) -> Result[Int, String]fn code39_checksum(data : String) -> Result[Int, String]fn code93_checksums(data : String, full_ascii? : Bool) -> Result[(Int, Int), String]fn gtin14_checksum(data : String) -> Result[Int, String]fn isbn10_valid(s : String) -> Boolfn issn_valid(s : String) -> Boolfn mod10_check(digits : String, odd_weight : Int, even_weight : Int) -> Result[Int, String]fn mod10_verify(digits : String, odd_weight : Int, even_weight : Int) -> Bool纯 MoonBit 原生的一维条码(1D barcode)生成、校验与渲染工具库:EAN-13 / EAN-8 / UPC-A / Code 39 / Code 93 / Code 128 / ITF-14 编码、ISBN / ISSN / GTIN 校验、SVG / ASCII / ANSI 渲染,可编译为 native / wasm / wasm-gc / js 多后端。
Dependencies