【问题标题】:How do I decode QR Code in Flutter for ZATCA specification如何在 Flutter 中为 ZATCA 规范解码 QR 码
【发布时间】:2021-11-29 18:22:01
【问题描述】:

我在颤动中读取了 ZATCA QR 码规范的二维码,但我如何解码以获得 as 对象或分隔字符串:

-Seller’s name
-VAT registration number of the seller
-Time stamp of the Electronic Invoice or Credit/Debit Note (date and time)
-VAT total
-Invoice total

我在 Flutter 中执行此代码:

var data = base64.decode(string as resultof qr code);
var utf8data = utf8.decode(data);

但是如何将 utf8data 解码为这样的字符串:

-Seller’s name
-VAT registration number of the seller
-Time stamp of the Electronic Invoice or Credit/Debit Note (date and time)
-VAT total
-Invoice total

【问题讨论】:

    标签: flutter decode


    【解决方案1】:

    用于在 PHP 中解码 QR 码 (Zatca)

    1. 读取二维码 - 示例 base64 码

    2. 解码base64码

    3. 使用 preg_replace 从字符串中删除 unicode 值

    示例代码

    $base64 = "AQZSYWZlZXECDTEyMzQ1Njc4OVQxMjUDFDIwMjEtMDctMTJUMTQ6MjU6MDlaBAM3ODYFAjI1";
    
    $decoded = base64_decode($base64);
    
    //print_r($decoded)
    //raw data
    //\u0001\u0006Rafeeq\u0002\t123456789\u0003\u00142021-07-12T14:25:09Z\u0004\u0003786\u0005\u000225
    
    $result_data = preg_replace('/[\x00-\x1F\x80-\xFF]/', ',', $decoded);
    
    $actula_data = explode(',,', $result_data);
    
    print_r($actula_data);
    

    输出:

    ["","Rafeeq","123456789T125","2021-07-12T14:25:09Z","786","25"]
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-01-05
      • 2018-09-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-07-22
      • 2021-08-29
      相关资源
      最近更新 更多