Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

If I put 12345, for example, in a "text" bar code's property, the output is 012345.

This "0" is the problem. How I can remove this?

I'm using Delphi 2010 and FastReport 4.9.72.

like image 286
André Avatar asked Dec 22 '22 02:12

André


2 Answers

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.

like image 89
Petesh Avatar answered Dec 23 '22 17:12

Petesh


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;
like image 24
Remy Lebeau Avatar answered Dec 23 '22 17:12

Remy Lebeau