How do I omit the leading 0 from a 128C bar code?

旧时模样 提交于 2019-12-05 12:36:50

A Code 128C barcode needs to be an even number of digits. This is by design.

There is a 1:1 mapping between the numbers and the resulting output, and the output is 2-digit aligned. In the case of 1 the Code 128C representation of this number is 01

if the value was 12 then the underlying representation would be 12

so the digits 628 can only be represented by 0628

The wikipedia article about Code 128 explains the differences between the 128A, 128B and 128C encodings.

To remove leading zeros from a string:

function RemoveLeadingZeros(const S: String): String;
var
  I, NumZeros: Integer;
begin
  Len := 0;
  for I := 1 to Length(S) do
  begin
    if S[I] <> '0' then Break;
    Inc(NumZeros);
  end;
  if NumZeros > 0 then
    Result := Copy(S, NumZeros+1, MaxInt)
  else
    Result := S:
end;
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!