标签:code 转换 span tab targe 函数 title int pre
Barcode2011版本, 在UnicodeIDE环境下原本二维码处理中文时有问题, 只读取了第一个字节转换, 所以中文会出错
修改psCodeStudio.pas文件,TpsQRCode.EncodePart函数
function TpsQRCode.EncodePart(const ToEncode:String; currMode: TpsQRMode):String; var i, j, k: integer; s, s1: String; k1, k2: integer; c: Char; lBytes: TBytes; begin i := 1; s := GetModeIndicator(FMicroQR, currMode, FUsedVersion); if currMode = QrBytes then begin lBytes := TEncoding.UTF8.GetBytes(ToEncode); s := s + IntegerToBits(Length(lBytes), GetNumberOfBitsIndicatorSize(FMicroQR, currMode, FUsedVersion)); end else begin lBytes := nil; s := s + IntegerToBits(Length(ToEncode), GetNumberOfBitsIndicatorSize(FMicroQR, currMode, FUsedVersion)); end; case currMode of QrNumeric: while i <= Length(ToEncode) do begin s1 := Copy(ToEncode, i, 3); k := 0; for j := 1 to Length(s1) do k := 10 * k + Ord(s1[j]) - Ord0; case Length(s1) of 1: s := s + IntegerToBits(k, 4); 2: s := s + IntegerToBits(k, 7); 3: s := s + IntegerToBits(k, 10); end; Inc(i, 3); end; QrAlphanumeric: while i <= Length(ToEncode) do begin c := ToEncode[i]; if (FNC1 <> fnc1None) and (Char(c) = GS1_GroupSeparator) then c := ‘%‘; k1 := System.Pos(c, QR_AlphaTable) - 1; if k1 = -1 then begin s := ‘‘; Exit; end; Inc(i); if i <= Length(ToEncode) then begin c := ToEncode[i]; if (FNC1 <> fnc1None) and (Char(c) = GS1_GroupSeparator) then c := ‘%‘; k2 := Pos(c, QR_AlphaTable) - 1; if k2 = -1 then begin s := ‘‘; Exit; end; s := s + IntegerToBits(45 * k1 + k2, 11); end else s := s + IntegerToBits(k1, 6); Inc(i); end; QrBytes: begin for i := Low(lBytes) to High(lBytes) do s := s + IntegerToBits(lBytes[i], 8); end; QrKanji: ; end; result := s; end;
以下为修改完的文件
https://files.cnblogs.com/files/lzl_17948876/psCodeStudio.rar
标签:code 转换 span tab targe 函数 title int pre
原文地址:https://www.cnblogs.com/lzl_17948876/p/12144376.html