Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
BC_OnedEANChecksum.cpp
Go to the documentation of this file.
1// Copyright 2017 The PDFium Authors
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#include "fxbarcode/oned/BC_OnedEANChecksum.h"
6
7#include "core/fxcrt/fx_extension.h"
8
9int32_t EANCalcChecksum(const ByteString& contents) {
10 int32_t odd = 0;
11 int32_t even = 0;
12 size_t parity = 1;
13 for (size_t i = contents.GetLength(); i > 0; i--) {
14 if (parity % 2)
15 odd += FXSYS_DecimalCharToInt(contents[i - 1]);
16 else
17 even += FXSYS_DecimalCharToInt(contents[i - 1]);
18 parity++;
19 }
20 return (10 - (odd * 3 + even) % 10) % 10;
21}
int32_t EANCalcChecksum(const ByteString &contents)