title: Why is my Luhn checksum calculated correctly on Windows but not on Android?
body: <p>I get this <code>Luhn</code> function on Internet and it's correct when I compile it for Windows32 VCL. But when I compile it to use in an Android App I get a <code>False</code> instead of <code>True</code> and I suspect that it is because it is converting to <code>utf8</code> to byte expecting <code>ascii</code> to be converted.</p>
  
  <p>So what can I do to this function in order to work correctly on Android?</p>
  
  <pre><code>function Luhn(Code: string): Boolean;
  var
      i, sum: integer;
      temp: byte;
  begin
  { calcula o algorítimo luhn, usado no iccid }
      sum := 0;
      for i:= length(Code) downto 1 do
      begin  // Run the characters backwards
        temp := byte(Code[i])-48;             // Convert from ASCII to byte
        if (length(Code)-i) mod 2 = 0
          then sum := sum + temp             // Odd characters just add
          else if temp &lt; 5
             then sum := sum + 2*temp        // Even characters add double
             else sum := sum + (2*temp)-9;   // or sum the digits of the doubling
      end;
      Result := sum mod 10 = 0;              // Return true if sum ends in a 0
      if Result then
        Toast(Code+#13+'True')
      else
        Toast(Code+#13+'False');
  
  end;
  </code></pre>