react-native-nitro-zxing 0.1.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +34 -0
- package/VisionCameraZxing.podspec +48 -0
- package/android/CMakeLists.txt +43 -0
- package/android/build.gradle +150 -0
- package/android/fix-prefab.gradle +51 -0
- package/android/gradle.properties +5 -0
- package/android/src/main/AndroidManifest.xml +3 -0
- package/android/src/main/cpp/cpp-adapter.cpp +7 -0
- package/android/src/main/java/com/margelo/nitro/camera/zxing/VisionCameraZxingPackage.kt +21 -0
- package/cpp/BarcodeValueTypeClassifier.cpp +70 -0
- package/cpp/BarcodeValueTypeClassifier.hpp +14 -0
- package/cpp/FrameImageView.cpp +75 -0
- package/cpp/FrameImageView.hpp +34 -0
- package/cpp/HybridBarcode.cpp +59 -0
- package/cpp/HybridBarcode.hpp +26 -0
- package/cpp/HybridBarcodeScanner.cpp +121 -0
- package/cpp/HybridBarcodeScanner.hpp +26 -0
- package/cpp/HybridBarcodeScannerFactory.cpp +11 -0
- package/cpp/HybridBarcodeScannerFactory.hpp +14 -0
- package/cpp/ImageDownscaler.cpp +34 -0
- package/cpp/ImageDownscaler.hpp +21 -0
- package/cpp/ZXingDecoder.cpp +189 -0
- package/cpp/ZXingDecoder.hpp +72 -0
- package/cpp/zxing-core/LICENSE +202 -0
- package/cpp/zxing-core/README.md +156 -0
- package/cpp/zxing-core/core/CMakeLists.txt +784 -0
- package/cpp/zxing-core/core/Version.h.in +28 -0
- package/cpp/zxing-core/core/ZXingConfig.cmake.in +9 -0
- package/cpp/zxing-core/core/src/Barcode.cpp +255 -0
- package/cpp/zxing-core/core/src/Barcode.h +191 -0
- package/cpp/zxing-core/core/src/BarcodeData.h +100 -0
- package/cpp/zxing-core/core/src/BarcodeFormat.cpp +286 -0
- package/cpp/zxing-core/core/src/BarcodeFormat.h +272 -0
- package/cpp/zxing-core/core/src/BinaryBitmap.cpp +111 -0
- package/cpp/zxing-core/core/src/BinaryBitmap.h +66 -0
- package/cpp/zxing-core/core/src/BitArray.cpp +38 -0
- package/cpp/zxing-core/core/src/BitArray.h +181 -0
- package/cpp/zxing-core/core/src/BitMatrix.cpp +175 -0
- package/cpp/zxing-core/core/src/BitMatrix.h +199 -0
- package/cpp/zxing-core/core/src/BitMatrixCursor.h +253 -0
- package/cpp/zxing-core/core/src/BitMatrixIO.cpp +101 -0
- package/cpp/zxing-core/core/src/BitMatrixIO.h +21 -0
- package/cpp/zxing-core/core/src/BitSource.cpp +77 -0
- package/cpp/zxing-core/core/src/BitSource.h +72 -0
- package/cpp/zxing-core/core/src/ByteArray.h +42 -0
- package/cpp/zxing-core/core/src/CharacterSet.cpp +78 -0
- package/cpp/zxing-core/core/src/CharacterSet.h +58 -0
- package/cpp/zxing-core/core/src/ConcentricFinder.cpp +312 -0
- package/cpp/zxing-core/core/src/ConcentricFinder.h +156 -0
- package/cpp/zxing-core/core/src/Content.cpp +471 -0
- package/cpp/zxing-core/core/src/Content.h +82 -0
- package/cpp/zxing-core/core/src/ContentType.h +19 -0
- package/cpp/zxing-core/core/src/CreateBarcode.cpp +490 -0
- package/cpp/zxing-core/core/src/CreateBarcode.h +132 -0
- package/cpp/zxing-core/core/src/DecoderResult.h +92 -0
- package/cpp/zxing-core/core/src/DetectorResult.h +44 -0
- package/cpp/zxing-core/core/src/ECI.cpp +81 -0
- package/cpp/zxing-core/core/src/ECI.h +78 -0
- package/cpp/zxing-core/core/src/Error.cpp +29 -0
- package/cpp/zxing-core/core/src/Error.h +79 -0
- package/cpp/zxing-core/core/src/Flags.h +165 -0
- package/cpp/zxing-core/core/src/GTIN.cpp +253 -0
- package/cpp/zxing-core/core/src/GTIN.h +58 -0
- package/cpp/zxing-core/core/src/GlobalHistogramBinarizer.cpp +197 -0
- package/cpp/zxing-core/core/src/GlobalHistogramBinarizer.h +34 -0
- package/cpp/zxing-core/core/src/GridSampler.cpp +124 -0
- package/cpp/zxing-core/core/src/GridSampler.h +59 -0
- package/cpp/zxing-core/core/src/HRI.cpp +343 -0
- package/cpp/zxing-core/core/src/HRI.h +16 -0
- package/cpp/zxing-core/core/src/HybridBinarizer.cpp +315 -0
- package/cpp/zxing-core/core/src/HybridBinarizer.h +40 -0
- package/cpp/zxing-core/core/src/ImageView.h +168 -0
- package/cpp/zxing-core/core/src/JSON.cpp +154 -0
- package/cpp/zxing-core/core/src/JSON.h +66 -0
- package/cpp/zxing-core/core/src/LocalGrid.cpp +242 -0
- package/cpp/zxing-core/core/src/LocalGrid.h +91 -0
- package/cpp/zxing-core/core/src/LogMatrix.h +105 -0
- package/cpp/zxing-core/core/src/Matrix.h +125 -0
- package/cpp/zxing-core/core/src/MultiFormatReader.cpp +107 -0
- package/cpp/zxing-core/core/src/MultiFormatReader.h +34 -0
- package/cpp/zxing-core/core/src/MultiFormatWriter.cpp +111 -0
- package/cpp/zxing-core/core/src/MultiFormatWriter.h +62 -0
- package/cpp/zxing-core/core/src/Pattern.h +472 -0
- package/cpp/zxing-core/core/src/PerspectiveTransform.cpp +81 -0
- package/cpp/zxing-core/core/src/PerspectiveTransform.h +47 -0
- package/cpp/zxing-core/core/src/Point.h +185 -0
- package/cpp/zxing-core/core/src/Quadrilateral.h +215 -0
- package/cpp/zxing-core/core/src/Range.h +112 -0
- package/cpp/zxing-core/core/src/ReadBarcode.cpp +335 -0
- package/cpp/zxing-core/core/src/ReadBarcode.h +33 -0
- package/cpp/zxing-core/core/src/Reader.h +32 -0
- package/cpp/zxing-core/core/src/ReaderOptions.h +210 -0
- package/cpp/zxing-core/core/src/ReedSolomon.cpp +100 -0
- package/cpp/zxing-core/core/src/ReedSolomon.h +66 -0
- package/cpp/zxing-core/core/src/RegressionLine.h +161 -0
- package/cpp/zxing-core/core/src/ResultPoint.cpp +20 -0
- package/cpp/zxing-core/core/src/ResultPoint.h +35 -0
- package/cpp/zxing-core/core/src/StdGenerator.h +121 -0
- package/cpp/zxing-core/core/src/StdPrint.h +38 -0
- package/cpp/zxing-core/core/src/StdScope.h +55 -0
- package/cpp/zxing-core/core/src/StructuredAppend.h +19 -0
- package/cpp/zxing-core/core/src/SymbologyIdentifier.h +29 -0
- package/cpp/zxing-core/core/src/TextDecoder.cpp +59 -0
- package/cpp/zxing-core/core/src/TextDecoder.h +23 -0
- package/cpp/zxing-core/core/src/TextEncoder.cpp +75 -0
- package/cpp/zxing-core/core/src/TextEncoder.h +31 -0
- package/cpp/zxing-core/core/src/ThresholdBinarizer.h +58 -0
- package/cpp/zxing-core/core/src/TritMatrix.h +29 -0
- package/cpp/zxing-core/core/src/Utf.cpp +276 -0
- package/cpp/zxing-core/core/src/Utf.h +26 -0
- package/cpp/zxing-core/core/src/WhiteRectDetector.cpp +276 -0
- package/cpp/zxing-core/core/src/WhiteRectDetector.h +36 -0
- package/cpp/zxing-core/core/src/WriteBarcode.cpp +213 -0
- package/cpp/zxing-core/core/src/WriteBarcode.h +72 -0
- package/cpp/zxing-core/core/src/ZXAlgorithms.h +353 -0
- package/cpp/zxing-core/core/src/ZXConfig.h +17 -0
- package/cpp/zxing-core/core/src/ZXTestSupport.h +9 -0
- package/cpp/zxing-core/core/src/ZXVersion.h +14 -0
- package/cpp/zxing-core/core/src/ZXingC.cpp +460 -0
- package/cpp/zxing-core/core/src/ZXingC.h +296 -0
- package/cpp/zxing-core/core/src/ZXingCpp.cpp +18 -0
- package/cpp/zxing-core/core/src/ZXingCpp.h +76 -0
- package/cpp/zxing-core/core/src/ZXingQt.h +606 -0
- package/cpp/zxing-core/core/src/aztec/AZDecoder.cpp +376 -0
- package/cpp/zxing-core/core/src/aztec/AZDecoder.h +20 -0
- package/cpp/zxing-core/core/src/aztec/AZDetector.cpp +508 -0
- package/cpp/zxing-core/core/src/aztec/AZDetector.h +25 -0
- package/cpp/zxing-core/core/src/aztec/AZDetectorResult.h +51 -0
- package/cpp/zxing-core/core/src/aztec/AZEncoder.cpp +318 -0
- package/cpp/zxing-core/core/src/aztec/AZEncoder.h +44 -0
- package/cpp/zxing-core/core/src/aztec/AZEncodingState.h +40 -0
- package/cpp/zxing-core/core/src/aztec/AZHighLevelEncoder.cpp +377 -0
- package/cpp/zxing-core/core/src/aztec/AZHighLevelEncoder.h +36 -0
- package/cpp/zxing-core/core/src/aztec/AZReader.cpp +45 -0
- package/cpp/zxing-core/core/src/aztec/AZReader.h +21 -0
- package/cpp/zxing-core/core/src/aztec/AZToken.cpp +44 -0
- package/cpp/zxing-core/core/src/aztec/AZToken.h +39 -0
- package/cpp/zxing-core/core/src/aztec/AZWriter.cpp +38 -0
- package/cpp/zxing-core/core/src/aztec/AZWriter.h +55 -0
- package/cpp/zxing-core/core/src/datamatrix/DMBitLayout.cpp +194 -0
- package/cpp/zxing-core/core/src/datamatrix/DMBitLayout.h +21 -0
- package/cpp/zxing-core/core/src/datamatrix/DMDataBlock.cpp +63 -0
- package/cpp/zxing-core/core/src/datamatrix/DMDataBlock.h +41 -0
- package/cpp/zxing-core/core/src/datamatrix/DMDecoder.cpp +457 -0
- package/cpp/zxing-core/core/src/datamatrix/DMDecoder.h +19 -0
- package/cpp/zxing-core/core/src/datamatrix/DMDetector.cpp +1230 -0
- package/cpp/zxing-core/core/src/datamatrix/DMDetector.h +23 -0
- package/cpp/zxing-core/core/src/datamatrix/DMECEncoder.cpp +137 -0
- package/cpp/zxing-core/core/src/datamatrix/DMECEncoder.h +26 -0
- package/cpp/zxing-core/core/src/datamatrix/DMEncoderContext.h +128 -0
- package/cpp/zxing-core/core/src/datamatrix/DMHighLevelEncoder.cpp +919 -0
- package/cpp/zxing-core/core/src/datamatrix/DMHighLevelEncoder.h +29 -0
- package/cpp/zxing-core/core/src/datamatrix/DMReader.cpp +40 -0
- package/cpp/zxing-core/core/src/datamatrix/DMReader.h +21 -0
- package/cpp/zxing-core/core/src/datamatrix/DMSymbolInfo.cpp +141 -0
- package/cpp/zxing-core/core/src/datamatrix/DMSymbolInfo.h +78 -0
- package/cpp/zxing-core/core/src/datamatrix/DMSymbolShape.h +17 -0
- package/cpp/zxing-core/core/src/datamatrix/DMVersion.cpp +82 -0
- package/cpp/zxing-core/core/src/datamatrix/DMVersion.h +76 -0
- package/cpp/zxing-core/core/src/datamatrix/DMWriter.cpp +114 -0
- package/cpp/zxing-core/core/src/datamatrix/DMWriter.h +62 -0
- package/cpp/zxing-core/core/src/librscpp/README.md +65 -0
- package/cpp/zxing-core/core/src/librscpp/decode.h +258 -0
- package/cpp/zxing-core/core/src/librscpp/encode.h +124 -0
- package/cpp/zxing-core/core/src/librscpp/field.h +158 -0
- package/cpp/zxing-core/core/src/librscpp/poly.h +194 -0
- package/cpp/zxing-core/core/src/libzint/2of5inter.c +1 -0
- package/cpp/zxing-core/core/src/libzint/2of5inter_based.c +1 -0
- package/cpp/zxing-core/core/src/libzint/aztec.c +1 -0
- package/cpp/zxing-core/core/src/libzint/aztec.h +1 -0
- package/cpp/zxing-core/core/src/libzint/big5.h +1 -0
- package/cpp/zxing-core/core/src/libzint/codabar.c +1 -0
- package/cpp/zxing-core/core/src/libzint/code.c +1 -0
- package/cpp/zxing-core/core/src/libzint/code128.c +1 -0
- package/cpp/zxing-core/core/src/libzint/code128.h +1 -0
- package/cpp/zxing-core/core/src/libzint/common.c +1 -0
- package/cpp/zxing-core/core/src/libzint/common.h +1 -0
- package/cpp/zxing-core/core/src/libzint/dmatrix.c +1 -0
- package/cpp/zxing-core/core/src/libzint/dmatrix.h +1 -0
- package/cpp/zxing-core/core/src/libzint/dxfilmedge.c +1 -0
- package/cpp/zxing-core/core/src/libzint/eci.c +1 -0
- package/cpp/zxing-core/core/src/libzint/eci.h +1 -0
- package/cpp/zxing-core/core/src/libzint/eci_sb.h +1 -0
- package/cpp/zxing-core/core/src/libzint/filemem.c +1 -0
- package/cpp/zxing-core/core/src/libzint/filemem.h +1 -0
- package/cpp/zxing-core/core/src/libzint/fonts/normal_woff2.h +1 -0
- package/cpp/zxing-core/core/src/libzint/fonts/upcean_woff2.h +1 -0
- package/cpp/zxing-core/core/src/libzint/gb18030.h +1 -0
- package/cpp/zxing-core/core/src/libzint/gb2312.h +1 -0
- package/cpp/zxing-core/core/src/libzint/gbk.h +1 -0
- package/cpp/zxing-core/core/src/libzint/general_field.c +1 -0
- package/cpp/zxing-core/core/src/libzint/general_field.h +1 -0
- package/cpp/zxing-core/core/src/libzint/gs1.c +1 -0
- package/cpp/zxing-core/core/src/libzint/gs1.h +1 -0
- package/cpp/zxing-core/core/src/libzint/gs1_lint.h +1 -0
- package/cpp/zxing-core/core/src/libzint/iso3166.h +1 -0
- package/cpp/zxing-core/core/src/libzint/iso4217.h +1 -0
- package/cpp/zxing-core/core/src/libzint/ksx1001.h +1 -0
- package/cpp/zxing-core/core/src/libzint/large.c +1 -0
- package/cpp/zxing-core/core/src/libzint/large.h +1 -0
- package/cpp/zxing-core/core/src/libzint/library.c +1 -0
- package/cpp/zxing-core/core/src/libzint/maxicode.c +1 -0
- package/cpp/zxing-core/core/src/libzint/maxicode.h +1 -0
- package/cpp/zxing-core/core/src/libzint/medical.c +1 -0
- package/cpp/zxing-core/core/src/libzint/output.c +1 -0
- package/cpp/zxing-core/core/src/libzint/output.h +1 -0
- package/cpp/zxing-core/core/src/libzint/pdf417.c +1 -0
- package/cpp/zxing-core/core/src/libzint/pdf417.h +1 -0
- package/cpp/zxing-core/core/src/libzint/pdf417_tabs.h +1 -0
- package/cpp/zxing-core/core/src/libzint/qr.c +1 -0
- package/cpp/zxing-core/core/src/libzint/qr.h +1 -0
- package/cpp/zxing-core/core/src/libzint/raster.c +1 -0
- package/cpp/zxing-core/core/src/libzint/raster_font.h +1 -0
- package/cpp/zxing-core/core/src/libzint/reedsol.c +1 -0
- package/cpp/zxing-core/core/src/libzint/reedsol.h +1 -0
- package/cpp/zxing-core/core/src/libzint/reedsol_logs.h +1 -0
- package/cpp/zxing-core/core/src/libzint/rss.c +1 -0
- package/cpp/zxing-core/core/src/libzint/rss.h +1 -0
- package/cpp/zxing-core/core/src/libzint/sjis.h +1 -0
- package/cpp/zxing-core/core/src/libzint/stubs.c +137 -0
- package/cpp/zxing-core/core/src/libzint/svg.c +1 -0
- package/cpp/zxing-core/core/src/libzint/telepen.c +1 -0
- package/cpp/zxing-core/core/src/libzint/upcean.c +1 -0
- package/cpp/zxing-core/core/src/libzint/vector.c +1 -0
- package/cpp/zxing-core/core/src/libzint/zfiletypes.h +1 -0
- package/cpp/zxing-core/core/src/libzint/zint.h +1 -0
- package/cpp/zxing-core/core/src/libzint/zintconfig.h +1 -0
- package/cpp/zxing-core/core/src/libzueci/README.md +11 -0
- package/cpp/zxing-core/core/src/libzueci/zueci.c +1718 -0
- package/cpp/zxing-core/core/src/libzueci/zueci.h +179 -0
- package/cpp/zxing-core/core/src/libzueci/zueci_big5.h +3884 -0
- package/cpp/zxing-core/core/src/libzueci/zueci_common.h +31 -0
- package/cpp/zxing-core/core/src/libzueci/zueci_gb18030.h +264 -0
- package/cpp/zxing-core/core/src/libzueci/zueci_gb2312.h +2381 -0
- package/cpp/zxing-core/core/src/libzueci/zueci_gbk.h +4047 -0
- package/cpp/zxing-core/core/src/libzueci/zueci_ksx1001.h +2932 -0
- package/cpp/zxing-core/core/src/libzueci/zueci_sb.h +1112 -0
- package/cpp/zxing-core/core/src/libzueci/zueci_sjis.h +2286 -0
- package/cpp/zxing-core/core/src/maxicode/MCBitMatrixParser.cpp +68 -0
- package/cpp/zxing-core/core/src/maxicode/MCBitMatrixParser.h +30 -0
- package/cpp/zxing-core/core/src/maxicode/MCDecoder.cpp +329 -0
- package/cpp/zxing-core/core/src/maxicode/MCDecoder.h +19 -0
- package/cpp/zxing-core/core/src/maxicode/MCReader.cpp +65 -0
- package/cpp/zxing-core/core/src/maxicode/MCReader.h +21 -0
- package/cpp/zxing-core/core/src/oned/ODCodabarReader.cpp +102 -0
- package/cpp/zxing-core/core/src/oned/ODCodabarReader.h +21 -0
- package/cpp/zxing-core/core/src/oned/ODCodabarWriter.cpp +136 -0
- package/cpp/zxing-core/core/src/oned/ODCodabarWriter.h +34 -0
- package/cpp/zxing-core/core/src/oned/ODCode128Patterns.h +130 -0
- package/cpp/zxing-core/core/src/oned/ODCode128Reader.cpp +236 -0
- package/cpp/zxing-core/core/src/oned/ODCode128Reader.h +21 -0
- package/cpp/zxing-core/core/src/oned/ODCode128Writer.cpp +261 -0
- package/cpp/zxing-core/core/src/oned/ODCode128Writer.h +34 -0
- package/cpp/zxing-core/core/src/oned/ODCode39Reader.cpp +213 -0
- package/cpp/zxing-core/core/src/oned/ODCode39Reader.h +26 -0
- package/cpp/zxing-core/core/src/oned/ODCode39Writer.cpp +176 -0
- package/cpp/zxing-core/core/src/oned/ODCode39Writer.h +34 -0
- package/cpp/zxing-core/core/src/oned/ODCode93Patterns.h +80 -0
- package/cpp/zxing-core/core/src/oned/ODCode93Reader.cpp +112 -0
- package/cpp/zxing-core/core/src/oned/ODCode93Reader.h +21 -0
- package/cpp/zxing-core/core/src/oned/ODCode93Writer.cpp +192 -0
- package/cpp/zxing-core/core/src/oned/ODCode93Writer.h +32 -0
- package/cpp/zxing-core/core/src/oned/ODDXFilmEdgeReader.cpp +246 -0
- package/cpp/zxing-core/core/src/oned/ODDXFilmEdgeReader.h +26 -0
- package/cpp/zxing-core/core/src/oned/ODDataBarCommon.cpp +172 -0
- package/cpp/zxing-core/core/src/oned/ODDataBarCommon.h +204 -0
- package/cpp/zxing-core/core/src/oned/ODDataBarExpandedBitDecoder.cpp +253 -0
- package/cpp/zxing-core/core/src/oned/ODDataBarExpandedBitDecoder.h +19 -0
- package/cpp/zxing-core/core/src/oned/ODDataBarExpandedReader.cpp +383 -0
- package/cpp/zxing-core/core/src/oned/ODDataBarExpandedReader.h +25 -0
- package/cpp/zxing-core/core/src/oned/ODDataBarLimitedReader.cpp +163 -0
- package/cpp/zxing-core/core/src/oned/ODDataBarLimitedReader.h +23 -0
- package/cpp/zxing-core/core/src/oned/ODDataBarReader.cpp +240 -0
- package/cpp/zxing-core/core/src/oned/ODDataBarReader.h +25 -0
- package/cpp/zxing-core/core/src/oned/ODEAN13Writer.cpp +62 -0
- package/cpp/zxing-core/core/src/oned/ODEAN13Writer.h +34 -0
- package/cpp/zxing-core/core/src/oned/ODEAN8Writer.cpp +51 -0
- package/cpp/zxing-core/core/src/oned/ODEAN8Writer.h +34 -0
- package/cpp/zxing-core/core/src/oned/ODITFReader.cpp +97 -0
- package/cpp/zxing-core/core/src/oned/ODITFReader.h +33 -0
- package/cpp/zxing-core/core/src/oned/ODITFWriter.cpp +78 -0
- package/cpp/zxing-core/core/src/oned/ODITFWriter.h +34 -0
- package/cpp/zxing-core/core/src/oned/ODMultiUPCEANReader.cpp +323 -0
- package/cpp/zxing-core/core/src/oned/ODMultiUPCEANReader.h +32 -0
- package/cpp/zxing-core/core/src/oned/ODReader.cpp +259 -0
- package/cpp/zxing-core/core/src/oned/ODReader.h +35 -0
- package/cpp/zxing-core/core/src/oned/ODRowReader.h +222 -0
- package/cpp/zxing-core/core/src/oned/ODTelepenReader.cpp +199 -0
- package/cpp/zxing-core/core/src/oned/ODTelepenReader.h +25 -0
- package/cpp/zxing-core/core/src/oned/ODUPCAWriter.cpp +33 -0
- package/cpp/zxing-core/core/src/oned/ODUPCAWriter.h +34 -0
- package/cpp/zxing-core/core/src/oned/ODUPCEANCommon.cpp +80 -0
- package/cpp/zxing-core/core/src/oned/ODUPCEANCommon.h +129 -0
- package/cpp/zxing-core/core/src/oned/ODUPCEWriter.cpp +56 -0
- package/cpp/zxing-core/core/src/oned/ODUPCEWriter.h +34 -0
- package/cpp/zxing-core/core/src/oned/ODWriterHelper.cpp +39 -0
- package/cpp/zxing-core/core/src/oned/ODWriterHelper.h +48 -0
- package/cpp/zxing-core/core/src/pdf417/MicroPDFReader.cpp +796 -0
- package/cpp/zxing-core/core/src/pdf417/MicroPDFReader.h +23 -0
- package/cpp/zxing-core/core/src/pdf417/PDF417.cpp +85 -0
- package/cpp/zxing-core/core/src/pdf417/PDF417.h +81 -0
- package/cpp/zxing-core/core/src/pdf417/PDFBarcodeMetadata.h +53 -0
- package/cpp/zxing-core/core/src/pdf417/PDFBarcodeValue.cpp +48 -0
- package/cpp/zxing-core/core/src/pdf417/PDFBarcodeValue.h +38 -0
- package/cpp/zxing-core/core/src/pdf417/PDFBoundingBox.cpp +116 -0
- package/cpp/zxing-core/core/src/pdf417/PDFBoundingBox.h +75 -0
- package/cpp/zxing-core/core/src/pdf417/PDFCodeword.h +71 -0
- package/cpp/zxing-core/core/src/pdf417/PDFCodewordDecoder.cpp +588 -0
- package/cpp/zxing-core/core/src/pdf417/PDFCodewordDecoder.h +41 -0
- package/cpp/zxing-core/core/src/pdf417/PDFCompaction.h +20 -0
- package/cpp/zxing-core/core/src/pdf417/PDFCustomData.h +32 -0
- package/cpp/zxing-core/core/src/pdf417/PDFDecoder.cpp +725 -0
- package/cpp/zxing-core/core/src/pdf417/PDFDecoder.h +20 -0
- package/cpp/zxing-core/core/src/pdf417/PDFDetectionResult.cpp +247 -0
- package/cpp/zxing-core/core/src/pdf417/PDFDetectionResult.h +74 -0
- package/cpp/zxing-core/core/src/pdf417/PDFDetectionResultColumn.cpp +321 -0
- package/cpp/zxing-core/core/src/pdf417/PDFDetectionResultColumn.h +83 -0
- package/cpp/zxing-core/core/src/pdf417/PDFDetector.cpp +371 -0
- package/cpp/zxing-core/core/src/pdf417/PDFDetector.h +45 -0
- package/cpp/zxing-core/core/src/pdf417/PDFEncoder.cpp +570 -0
- package/cpp/zxing-core/core/src/pdf417/PDFEncoder.h +182 -0
- package/cpp/zxing-core/core/src/pdf417/PDFHighLevelEncoder.cpp +570 -0
- package/cpp/zxing-core/core/src/pdf417/PDFHighLevelEncoder.h +32 -0
- package/cpp/zxing-core/core/src/pdf417/PDFReader.cpp +333 -0
- package/cpp/zxing-core/core/src/pdf417/PDFReader.h +28 -0
- package/cpp/zxing-core/core/src/pdf417/PDFScanningDecoder.cpp +559 -0
- package/cpp/zxing-core/core/src/pdf417/PDFScanningDecoder.h +41 -0
- package/cpp/zxing-core/core/src/pdf417/PDFWriter.cpp +170 -0
- package/cpp/zxing-core/core/src/pdf417/PDFWriter.h +74 -0
- package/cpp/zxing-core/core/src/pdf417/ZXBigInteger.cpp +623 -0
- package/cpp/zxing-core/core/src/pdf417/ZXBigInteger.h +81 -0
- package/cpp/zxing-core/core/src/pdf417/ZXNullable.h +105 -0
- package/cpp/zxing-core/core/src/qrcode/QRBitMatrixParser.cpp +294 -0
- package/cpp/zxing-core/core/src/qrcode/QRBitMatrixParser.h +41 -0
- package/cpp/zxing-core/core/src/qrcode/QRCodecMode.cpp +95 -0
- package/cpp/zxing-core/core/src/qrcode/QRCodecMode.h +59 -0
- package/cpp/zxing-core/core/src/qrcode/QRDataBlock.cpp +93 -0
- package/cpp/zxing-core/core/src/qrcode/QRDataBlock.h +52 -0
- package/cpp/zxing-core/core/src/qrcode/QRDataMask.h +50 -0
- package/cpp/zxing-core/core/src/qrcode/QRDecoder.cpp +359 -0
- package/cpp/zxing-core/core/src/qrcode/QRDecoder.h +19 -0
- package/cpp/zxing-core/core/src/qrcode/QRDetector.cpp +920 -0
- package/cpp/zxing-core/core/src/qrcode/QRDetector.h +45 -0
- package/cpp/zxing-core/core/src/qrcode/QRECB.h +52 -0
- package/cpp/zxing-core/core/src/qrcode/QREncodeResult.h +33 -0
- package/cpp/zxing-core/core/src/qrcode/QREncoder.cpp +568 -0
- package/cpp/zxing-core/core/src/qrcode/QREncoder.h +21 -0
- package/cpp/zxing-core/core/src/qrcode/QRErrorCorrectionLevel.cpp +51 -0
- package/cpp/zxing-core/core/src/qrcode/QRErrorCorrectionLevel.h +39 -0
- package/cpp/zxing-core/core/src/qrcode/QRFormatInformation.cpp +160 -0
- package/cpp/zxing-core/core/src/qrcode/QRFormatInformation.h +61 -0
- package/cpp/zxing-core/core/src/qrcode/QRMaskUtil.cpp +156 -0
- package/cpp/zxing-core/core/src/qrcode/QRMaskUtil.h +15 -0
- package/cpp/zxing-core/core/src/qrcode/QRMatrixUtil.cpp +318 -0
- package/cpp/zxing-core/core/src/qrcode/QRMatrixUtil.h +25 -0
- package/cpp/zxing-core/core/src/qrcode/QRReader.cpp +149 -0
- package/cpp/zxing-core/core/src/qrcode/QRReader.h +21 -0
- package/cpp/zxing-core/core/src/qrcode/QRVersion.cpp +754 -0
- package/cpp/zxing-core/core/src/qrcode/QRVersion.h +127 -0
- package/cpp/zxing-core/core/src/qrcode/QRWriter.cpp +51 -0
- package/cpp/zxing-core/core/src/qrcode/QRWriter.h +74 -0
- package/cpp/zxing-core/core/version.rc.in +34 -0
- package/cpp/zxing-core/core/zxing.pc.in +8 -0
- package/cpp/zxing-core/wrappers/ios/README.md +25 -0
- package/cpp/zxing-core/wrappers/ios/Sources/Wrapper/Version.h +29 -0
- package/cpp/zxing-core/zxing-cpp.podspec +45 -0
- package/lib/factory.d.ts +10 -0
- package/lib/factory.js +12 -0
- package/lib/index.d.ts +9 -0
- package/lib/index.js +9 -0
- package/lib/specs/Barcode.nitro.d.ts +63 -0
- package/lib/specs/Barcode.nitro.js +1 -0
- package/lib/specs/BarcodeFormat.d.ts +11 -0
- package/lib/specs/BarcodeFormat.js +1 -0
- package/lib/specs/BarcodeScanner.nitro.d.ts +89 -0
- package/lib/specs/BarcodeScanner.nitro.js +1 -0
- package/lib/specs/BarcodeScannerFactory.nitro.d.ts +26 -0
- package/lib/specs/BarcodeScannerFactory.nitro.js +1 -0
- package/lib/specs/BarcodeValueType.d.ts +9 -0
- package/lib/specs/BarcodeValueType.js +1 -0
- package/lib/specs/Point.d.ts +14 -0
- package/lib/specs/Point.js +1 -0
- package/lib/specs/Rect.d.ts +22 -0
- package/lib/specs/Rect.js +1 -0
- package/lib/useBarcodeScanner.d.ts +23 -0
- package/lib/useBarcodeScanner.js +25 -0
- package/nitro.json +20 -0
- package/nitrogen/generated/.gitattributes +1 -0
- package/nitrogen/generated/android/VisionCameraZxing+autolinking.cmake +83 -0
- package/nitrogen/generated/android/VisionCameraZxing+autolinking.gradle +27 -0
- package/nitrogen/generated/android/VisionCameraZxingOnLoad.cpp +49 -0
- package/nitrogen/generated/android/VisionCameraZxingOnLoad.hpp +34 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/camera/zxing/VisionCameraZxingOnLoad.kt +35 -0
- package/nitrogen/generated/ios/VisionCameraZxing+autolinking.rb +62 -0
- package/nitrogen/generated/ios/VisionCameraZxing-Swift-Cxx-Bridge.cpp +17 -0
- package/nitrogen/generated/ios/VisionCameraZxing-Swift-Cxx-Bridge.hpp +27 -0
- package/nitrogen/generated/ios/VisionCameraZxing-Swift-Cxx-Umbrella.hpp +38 -0
- package/nitrogen/generated/ios/VisionCameraZxingAutolinking.mm +35 -0
- package/nitrogen/generated/ios/VisionCameraZxingAutolinking.swift +16 -0
- package/nitrogen/generated/shared/c++/BarcodeFormat.hpp +124 -0
- package/nitrogen/generated/shared/c++/BarcodeScannerOptions.hpp +85 -0
- package/nitrogen/generated/shared/c++/BarcodeValueType.hpp +120 -0
- package/nitrogen/generated/shared/c++/HybridBarcodeScannerSpec.cpp +23 -0
- package/nitrogen/generated/shared/c++/HybridBarcodeScannerSpec.hpp +74 -0
- package/nitrogen/generated/shared/c++/HybridBarcodeSpec.cpp +27 -0
- package/nitrogen/generated/shared/c++/HybridBarcodeSpec.hpp +82 -0
- package/nitrogen/generated/shared/c++/HybridZXingBarcodeScannerFactorySpec.cpp +21 -0
- package/nitrogen/generated/shared/c++/HybridZXingBarcodeScannerFactorySpec.hpp +67 -0
- package/nitrogen/generated/shared/c++/Point.hpp +87 -0
- package/nitrogen/generated/shared/c++/Rect.hpp +95 -0
- package/nitrogen/generated/shared/c++/TargetBarcodeFormat.hpp +124 -0
- package/package.json +108 -0
- package/react-native.config.js +16 -0
- package/src/factory.ts +26 -0
- package/src/index.ts +9 -0
- package/src/specs/Barcode.nitro.ts +70 -0
- package/src/specs/BarcodeFormat.ts +31 -0
- package/src/specs/BarcodeScanner.nitro.ts +91 -0
- package/src/specs/BarcodeScannerFactory.nitro.ts +27 -0
- package/src/specs/BarcodeValueType.ts +25 -0
- package/src/specs/Point.ts +14 -0
- package/src/specs/Rect.ts +22 -0
- package/src/useBarcodeScanner.ts +36 -0
|
@@ -0,0 +1,471 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2022 Axel Waggershauser
|
|
3
|
+
*/
|
|
4
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
|
|
6
|
+
#include "Content.h"
|
|
7
|
+
|
|
8
|
+
#include "ByteArray.h"
|
|
9
|
+
#include "CharacterSet.h"
|
|
10
|
+
#include "ECI.h"
|
|
11
|
+
#include "HRI.h"
|
|
12
|
+
#include "TextDecoder.h"
|
|
13
|
+
#include "Utf.h"
|
|
14
|
+
#include "ZXAlgorithms.h"
|
|
15
|
+
#include "Version.h"
|
|
16
|
+
|
|
17
|
+
#include <cassert>
|
|
18
|
+
|
|
19
|
+
namespace ZXing {
|
|
20
|
+
|
|
21
|
+
std::string ToString(ContentType type)
|
|
22
|
+
{
|
|
23
|
+
const char* t2s[] = {"Text", "Binary", "Mixed", "GS1", "ISO15434", "UnknownECI"};
|
|
24
|
+
int idx = static_cast<int>(type);
|
|
25
|
+
if (idx < 0 || idx >= Size(t2s))
|
|
26
|
+
return "InvalidContentType";
|
|
27
|
+
return t2s[idx];
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
template <typename FUNC>
|
|
31
|
+
void Content::ForEachECIBlock(FUNC func) const
|
|
32
|
+
{
|
|
33
|
+
ECI defaultECI = hasECI ? ECI::ISO8859_1 : ECI::Unknown;
|
|
34
|
+
if (encodings.empty())
|
|
35
|
+
func(defaultECI, 0, Size(bytes));
|
|
36
|
+
else if (encodings.front().pos != 0)
|
|
37
|
+
func(defaultECI, 0, encodings.front().pos);
|
|
38
|
+
|
|
39
|
+
for (int i = 0; i < Size(encodings); ++i) {
|
|
40
|
+
auto [eci, start] = encodings[i];
|
|
41
|
+
int end = i + 1 == Size(encodings) ? Size(bytes) : encodings[i + 1].pos;
|
|
42
|
+
|
|
43
|
+
if (start != end)
|
|
44
|
+
func(eci, start, end);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
void Content::switchEncoding(ECI eci, bool isECI)
|
|
49
|
+
{
|
|
50
|
+
// remove all non-ECI entries on first ECI entry
|
|
51
|
+
if (isECI && !hasECI)
|
|
52
|
+
encodings.clear();
|
|
53
|
+
if (isECI || !hasECI)
|
|
54
|
+
encodings.push_back({eci, Size(bytes)});
|
|
55
|
+
|
|
56
|
+
hasECI |= isECI;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
Content::Content(ByteArray&& bytes, SymbologyIdentifier si, CharacterSet defaultCharset)
|
|
60
|
+
: bytes(std::move(bytes)), symbology(si), defaultCharset(defaultCharset) {}
|
|
61
|
+
|
|
62
|
+
void Content::switchEncoding(CharacterSet cs)
|
|
63
|
+
{
|
|
64
|
+
switchEncoding(ToECI(cs), false);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
void Content::append(const Content& other)
|
|
68
|
+
{
|
|
69
|
+
if (!hasECI && other.hasECI)
|
|
70
|
+
encodings.clear();
|
|
71
|
+
if (other.hasECI || !hasECI)
|
|
72
|
+
for (auto& e : other.encodings)
|
|
73
|
+
encodings.push_back({e.eci, Size(bytes) + e.pos});
|
|
74
|
+
append(other.bytes);
|
|
75
|
+
|
|
76
|
+
hasECI |= other.hasECI;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
void Content::erase(int pos, int n)
|
|
80
|
+
{
|
|
81
|
+
bytes.erase(bytes.begin() + pos, bytes.begin() + pos + n);
|
|
82
|
+
for (auto& e : encodings)
|
|
83
|
+
if (e.pos > pos)
|
|
84
|
+
e.pos -= n;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
void Content::insert(int pos, std::string_view str)
|
|
88
|
+
{
|
|
89
|
+
bytes.insert(bytes.begin() + pos, str.begin(), str.end());
|
|
90
|
+
for (auto& e : encodings)
|
|
91
|
+
if (e.pos > pos)
|
|
92
|
+
e.pos += Size(str);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
bool Content::canProcess() const
|
|
96
|
+
{
|
|
97
|
+
return std::all_of(encodings.begin(), encodings.end(), [](Encoding e) { return CanProcess(e.eci); });
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
std::string Content::render(bool withECI) const
|
|
101
|
+
{
|
|
102
|
+
if (empty() || !canProcess())
|
|
103
|
+
return {};
|
|
104
|
+
|
|
105
|
+
#ifdef ZXING_READERS
|
|
106
|
+
std::string res;
|
|
107
|
+
res.reserve(bytes.size() * 2);
|
|
108
|
+
if (withECI)
|
|
109
|
+
res += symbology.toString(true);
|
|
110
|
+
ECI lastECI = ECI::Unknown;
|
|
111
|
+
auto fallbackCS = defaultCharset;
|
|
112
|
+
if (!hasECI && fallbackCS == CharacterSet::Unknown)
|
|
113
|
+
fallbackCS = guessEncoding();
|
|
114
|
+
|
|
115
|
+
ForEachECIBlock([&](ECI eci, int begin, int end) {
|
|
116
|
+
// basic idea: if IsText(eci), we transcode it to UTF8, otherwise we treat it as binary but
|
|
117
|
+
// transcoded it to valid UTF8 bytes sequences representing the code points 0-255. The eci we report
|
|
118
|
+
// back to the caller by inserting their "\XXXXXX" ECI designator is UTF8 for text and
|
|
119
|
+
// the original ECI for everything else.
|
|
120
|
+
// first determine how to decode the content (use fallback if unknown)
|
|
121
|
+
auto inEci = IsText(eci) ? eci : eci == ECI::Unknown ? ToECI(fallbackCS) : ECI::Binary;
|
|
122
|
+
if (withECI) {
|
|
123
|
+
// then find the eci to report back in the ECI designator
|
|
124
|
+
auto outEci = IsText(inEci) ? ECI::UTF8 : eci;
|
|
125
|
+
|
|
126
|
+
if (lastECI != outEci)
|
|
127
|
+
res += ToString(outEci);
|
|
128
|
+
lastECI = outEci;
|
|
129
|
+
|
|
130
|
+
for (auto c : BytesToUtf8(bytes.asView(begin, end - begin), inEci)) {
|
|
131
|
+
res += c;
|
|
132
|
+
if (c == '\\') // in the ECI protocol a '\' (0x5c) has to be doubled, works only because 0x5c can only mean `\`
|
|
133
|
+
res += c;
|
|
134
|
+
}
|
|
135
|
+
} else {
|
|
136
|
+
res += BytesToUtf8(bytes.asView(begin, end - begin), inEci);
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
return res;
|
|
141
|
+
#elif defined(ZXING_USE_ZINT)
|
|
142
|
+
assert(!utf8Cache.empty());
|
|
143
|
+
if (!withECI)
|
|
144
|
+
return std::accumulate(utf8Cache.begin(), utf8Cache.end(), std::string());
|
|
145
|
+
|
|
146
|
+
std::string res;
|
|
147
|
+
res.reserve(3 + TransformReduce(utf8Cache, 0, std::size<std::string>) * 2 + encodings.size() * 7);
|
|
148
|
+
res += symbology.toString(true);
|
|
149
|
+
|
|
150
|
+
ECI lastECI = ECI::Unknown;
|
|
151
|
+
auto fallbackCS = defaultCharset;
|
|
152
|
+
if (!hasECI && fallbackCS == CharacterSet::Unknown)
|
|
153
|
+
fallbackCS = guessEncoding();
|
|
154
|
+
|
|
155
|
+
assert(utf8Cache.size() == encodings.size());
|
|
156
|
+
for (int i = 0; i < Size(encodings); ++i) {
|
|
157
|
+
const auto eci = encodings[i].eci;
|
|
158
|
+
const auto inEci = IsText(eci) ? eci : eci == ECI::Unknown ? ToECI(fallbackCS) : ECI::Binary;
|
|
159
|
+
const auto outEci = IsText(inEci) ? ECI::UTF8 : eci;
|
|
160
|
+
|
|
161
|
+
if (lastECI != outEci)
|
|
162
|
+
res += ToString(outEci);
|
|
163
|
+
lastECI = outEci;
|
|
164
|
+
|
|
165
|
+
for (auto c : utf8Cache[i]) {
|
|
166
|
+
res += c;
|
|
167
|
+
if (c == '\\') // in the ECI protocol a '\' (0x5c) has to be doubled, works only because 0x5c can only mean `\`
|
|
168
|
+
res += c;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
return res;
|
|
173
|
+
#else
|
|
174
|
+
(void)withECI;
|
|
175
|
+
return std::string(bytes.asString());
|
|
176
|
+
#endif
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
std::string Content::text(TextMode mode) const
|
|
180
|
+
{
|
|
181
|
+
switch (mode) {
|
|
182
|
+
case TextMode::Plain: return render(false);
|
|
183
|
+
case TextMode::ECI: return render(true);
|
|
184
|
+
case TextMode::HRI:
|
|
185
|
+
switch (type()) {
|
|
186
|
+
#if defined(ZXING_READERS) || defined(ZXING_USE_ZINT)
|
|
187
|
+
case ContentType::GS1: {
|
|
188
|
+
auto plain = render(false);
|
|
189
|
+
auto hri = HRIFromGS1(plain);
|
|
190
|
+
return hri.empty() ? EscapeNonGraphical(plain) : hri;
|
|
191
|
+
}
|
|
192
|
+
case ContentType::ISO15434: return HRIFromISO15434(render(false));
|
|
193
|
+
case ContentType::Text: return render(false);
|
|
194
|
+
#endif
|
|
195
|
+
default: return text(TextMode::Escaped);
|
|
196
|
+
}
|
|
197
|
+
case TextMode::Escaped: return EscapeNonGraphical(render(false));
|
|
198
|
+
case TextMode::Hex: return ToHex(bytes);
|
|
199
|
+
case TextMode::HexECI: return ToHex(bytesECI());
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
return {}; // silence compiler warning
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
std::wstring Content::utfW() const
|
|
206
|
+
{
|
|
207
|
+
return FromUtf8(render(false));
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
ByteArray Content::bytesECI() const
|
|
211
|
+
{
|
|
212
|
+
if (empty())
|
|
213
|
+
return {};
|
|
214
|
+
|
|
215
|
+
ByteArray res;
|
|
216
|
+
res.reserve(3 + bytes.size() + hasECI * encodings.size() * 7);
|
|
217
|
+
|
|
218
|
+
// report ECI protocol only if actually found ECI data in the barode bit stream
|
|
219
|
+
// see also https://github.com/zxing-cpp/zxing-cpp/issues/936
|
|
220
|
+
res.append(symbology.toString(hasECI));
|
|
221
|
+
|
|
222
|
+
if (hasECI)
|
|
223
|
+
ForEachECIBlock([&](ECI eci, int begin, int end) {
|
|
224
|
+
if (hasECI)
|
|
225
|
+
res.append(ToString(eci));
|
|
226
|
+
|
|
227
|
+
for (auto b : bytes.asView(begin, end - begin)) {
|
|
228
|
+
res.push_back(b);
|
|
229
|
+
if (b == '\\') // in the ECI protocol a '\' has to be doubled
|
|
230
|
+
res.push_back(b);
|
|
231
|
+
}
|
|
232
|
+
});
|
|
233
|
+
else
|
|
234
|
+
res.append(bytes);
|
|
235
|
+
|
|
236
|
+
return res;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
#if defined(ZXING_READERS) || defined(ZXING_USE_ZINT)
|
|
240
|
+
/**
|
|
241
|
+
* @param bytes bytes encoding a string, whose encoding should be guessed
|
|
242
|
+
* @return name of guessed encoding; at the moment will only guess one of:
|
|
243
|
+
* {@link #SHIFT_JIS}, {@link #UTF8}, {@link #ISO88591}, or the platform
|
|
244
|
+
* default encoding if none of these can possibly be correct
|
|
245
|
+
*/
|
|
246
|
+
CharacterSet GuessTextEncoding(ByteView bytes, CharacterSet fallback = CharacterSet::ISO8859_1)
|
|
247
|
+
{
|
|
248
|
+
// For now, merely tries to distinguish ISO-8859-1, UTF-8 and Shift_JIS,
|
|
249
|
+
// which should be by far the most common encodings.
|
|
250
|
+
bool canBeISO88591 = true;
|
|
251
|
+
bool canBeShiftJIS = true;
|
|
252
|
+
bool canBeUTF8 = IsValidUtf8(bytes);
|
|
253
|
+
int utf8BytesLeft = 0;
|
|
254
|
+
//int utf8LowChars = 0;
|
|
255
|
+
int utf2BytesChars = 0;
|
|
256
|
+
int utf3BytesChars = 0;
|
|
257
|
+
int utf4BytesChars = 0;
|
|
258
|
+
int sjisBytesLeft = 0;
|
|
259
|
+
//int sjisLowChars = 0;
|
|
260
|
+
int sjisKatakanaChars = 0;
|
|
261
|
+
//int sjisDoubleBytesChars = 0;
|
|
262
|
+
int sjisCurKatakanaWordLength = 0;
|
|
263
|
+
int sjisCurDoubleBytesWordLength = 0;
|
|
264
|
+
int sjisMaxKatakanaWordLength = 0;
|
|
265
|
+
int sjisMaxDoubleBytesWordLength = 0;
|
|
266
|
+
//int isoLowChars = 0;
|
|
267
|
+
//int isoHighChars = 0;
|
|
268
|
+
int isoHighOther = 0;
|
|
269
|
+
|
|
270
|
+
bool utf8bom = bytes.size() > 3 && bytes[0] == 0xEF && bytes[1] == 0xBB && bytes[2] == 0xBF;
|
|
271
|
+
|
|
272
|
+
for (int value : bytes)
|
|
273
|
+
{
|
|
274
|
+
if(!(canBeISO88591 || canBeShiftJIS || canBeUTF8))
|
|
275
|
+
break;
|
|
276
|
+
|
|
277
|
+
// UTF-8 stuff
|
|
278
|
+
if (canBeUTF8) {
|
|
279
|
+
if (utf8BytesLeft > 0) {
|
|
280
|
+
if ((value & 0x80) == 0) {
|
|
281
|
+
canBeUTF8 = false;
|
|
282
|
+
}
|
|
283
|
+
else {
|
|
284
|
+
utf8BytesLeft--;
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
else if ((value & 0x80) != 0) {
|
|
288
|
+
if ((value & 0x40) == 0) {
|
|
289
|
+
canBeUTF8 = false;
|
|
290
|
+
}
|
|
291
|
+
else {
|
|
292
|
+
utf8BytesLeft++;
|
|
293
|
+
if ((value & 0x20) == 0) {
|
|
294
|
+
utf2BytesChars++;
|
|
295
|
+
}
|
|
296
|
+
else {
|
|
297
|
+
utf8BytesLeft++;
|
|
298
|
+
if ((value & 0x10) == 0) {
|
|
299
|
+
utf3BytesChars++;
|
|
300
|
+
}
|
|
301
|
+
else {
|
|
302
|
+
utf8BytesLeft++;
|
|
303
|
+
if ((value & 0x08) == 0) {
|
|
304
|
+
utf4BytesChars++;
|
|
305
|
+
}
|
|
306
|
+
else {
|
|
307
|
+
canBeUTF8 = false;
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
} //else {
|
|
313
|
+
//utf8LowChars++;
|
|
314
|
+
//}
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
// ISO-8859-1 stuff
|
|
318
|
+
if (canBeISO88591) {
|
|
319
|
+
if (value > 0x7F && value < 0xA0) {
|
|
320
|
+
canBeISO88591 = false;
|
|
321
|
+
}
|
|
322
|
+
else if (value > 0x9F) {
|
|
323
|
+
if (value < 0xC0 || value == 0xD7 || value == 0xF7) {
|
|
324
|
+
isoHighOther++;
|
|
325
|
+
} //else {
|
|
326
|
+
//isoHighChars++;
|
|
327
|
+
//}
|
|
328
|
+
} //else {
|
|
329
|
+
//isoLowChars++;
|
|
330
|
+
//}
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
// Shift_JIS stuff
|
|
334
|
+
if (canBeShiftJIS) {
|
|
335
|
+
if (sjisBytesLeft > 0) {
|
|
336
|
+
if (value < 0x40 || value == 0x7F || value > 0xFC) {
|
|
337
|
+
canBeShiftJIS = false;
|
|
338
|
+
}
|
|
339
|
+
else {
|
|
340
|
+
sjisBytesLeft--;
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
else if (value == 0x80 || value == 0xA0 || value > 0xEF || (value < 0x20 && value != 0xa && value != 0xd)) {
|
|
344
|
+
canBeShiftJIS = false; // use non-printable ASCII as indication for binary content
|
|
345
|
+
}
|
|
346
|
+
else if (value > 0xA0 && value < 0xE0) {
|
|
347
|
+
sjisKatakanaChars++;
|
|
348
|
+
sjisCurDoubleBytesWordLength = 0;
|
|
349
|
+
sjisCurKatakanaWordLength++;
|
|
350
|
+
if (sjisCurKatakanaWordLength > sjisMaxKatakanaWordLength) {
|
|
351
|
+
sjisMaxKatakanaWordLength = sjisCurKatakanaWordLength;
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
else if (value > 0x7F) {
|
|
355
|
+
sjisBytesLeft++;
|
|
356
|
+
//sjisDoubleBytesChars++;
|
|
357
|
+
sjisCurKatakanaWordLength = 0;
|
|
358
|
+
sjisCurDoubleBytesWordLength++;
|
|
359
|
+
if (sjisCurDoubleBytesWordLength > sjisMaxDoubleBytesWordLength) {
|
|
360
|
+
sjisMaxDoubleBytesWordLength = sjisCurDoubleBytesWordLength;
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
else {
|
|
364
|
+
//sjisLowChars++;
|
|
365
|
+
sjisCurKatakanaWordLength = 0;
|
|
366
|
+
sjisCurDoubleBytesWordLength = 0;
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
if (canBeUTF8 && utf8BytesLeft > 0) {
|
|
372
|
+
canBeUTF8 = false;
|
|
373
|
+
}
|
|
374
|
+
if (canBeShiftJIS && sjisBytesLeft > 0) {
|
|
375
|
+
canBeShiftJIS = false;
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
// Easy -- if there is BOM or at least 1 valid not-single byte character (and no evidence it can't be UTF-8), done
|
|
379
|
+
if (canBeUTF8 && (utf8bom || utf2BytesChars + utf3BytesChars + utf4BytesChars > 0)) {
|
|
380
|
+
return CharacterSet::UTF8;
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
bool assumeShiftJIS = fallback == CharacterSet::Shift_JIS || fallback == CharacterSet::EUC_JP;
|
|
384
|
+
// Easy -- if assuming Shift_JIS or at least 3 valid consecutive not-ascii characters (and no evidence it can't be), done
|
|
385
|
+
if (canBeShiftJIS && (assumeShiftJIS || sjisMaxKatakanaWordLength >= 3 || sjisMaxDoubleBytesWordLength >= 3)) {
|
|
386
|
+
return CharacterSet::Shift_JIS;
|
|
387
|
+
}
|
|
388
|
+
// Distinguishing Shift_JIS and ISO-8859-1 can be a little tough for short words. The crude heuristic is:
|
|
389
|
+
// - If we saw
|
|
390
|
+
// - only two consecutive katakana chars in the whole text, or
|
|
391
|
+
// - at least 10% of bytes that could be "upper" not-alphanumeric Latin1,
|
|
392
|
+
// - then we conclude Shift_JIS, else ISO-8859-1
|
|
393
|
+
if (canBeISO88591 && canBeShiftJIS) {
|
|
394
|
+
return (sjisMaxKatakanaWordLength == 2 && sjisKatakanaChars == 2) || isoHighOther * 10 >= Size(bytes)
|
|
395
|
+
? CharacterSet::Shift_JIS : CharacterSet::ISO8859_1;
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
// Otherwise, try in order ISO-8859-1, Shift JIS, UTF-8 and fall back to default platform encoding
|
|
399
|
+
if (canBeISO88591) {
|
|
400
|
+
return CharacterSet::ISO8859_1;
|
|
401
|
+
}
|
|
402
|
+
if (canBeShiftJIS) {
|
|
403
|
+
return CharacterSet::Shift_JIS;
|
|
404
|
+
}
|
|
405
|
+
if (canBeUTF8) {
|
|
406
|
+
return CharacterSet::UTF8;
|
|
407
|
+
}
|
|
408
|
+
// Otherwise, we take a wild guess with platform encoding
|
|
409
|
+
return fallback;
|
|
410
|
+
}
|
|
411
|
+
#endif
|
|
412
|
+
|
|
413
|
+
CharacterSet Content::guessEncoding() const
|
|
414
|
+
{
|
|
415
|
+
#if defined(ZXING_READERS) || defined(ZXING_USE_ZINT)
|
|
416
|
+
// assemble all blocks with unknown encoding
|
|
417
|
+
ByteArray input;
|
|
418
|
+
ForEachECIBlock([&](ECI eci, int begin, int end) {
|
|
419
|
+
if (eci == ECI::Unknown)
|
|
420
|
+
input.append(bytes.asView(begin, end - begin));
|
|
421
|
+
});
|
|
422
|
+
|
|
423
|
+
if (input.empty())
|
|
424
|
+
return CharacterSet::Unknown;
|
|
425
|
+
|
|
426
|
+
return GuessTextEncoding(input);
|
|
427
|
+
#else
|
|
428
|
+
return CharacterSet::ISO8859_1;
|
|
429
|
+
#endif
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
ContentType Content::type() const
|
|
433
|
+
{
|
|
434
|
+
#if 1 //def ZXING_READERS
|
|
435
|
+
if (empty())
|
|
436
|
+
return ContentType::Text;
|
|
437
|
+
|
|
438
|
+
if (!canProcess())
|
|
439
|
+
return ContentType::UnknownECI;
|
|
440
|
+
|
|
441
|
+
if (symbology.aiFlag == AIFlag::GS1)
|
|
442
|
+
return ContentType::GS1;
|
|
443
|
+
|
|
444
|
+
// check for the absolute minimum of a ISO 15434 conforming message ("[)>" + RS + digit + digit)
|
|
445
|
+
if (bytes.size() > 6 && bytes.asString(0, 4) == "[)>\x1E" && IsDigit(bytes[4]) && IsDigit(bytes[5]))
|
|
446
|
+
return ContentType::ISO15434;
|
|
447
|
+
|
|
448
|
+
ECI fallback = ToECI(guessEncoding());
|
|
449
|
+
std::vector<bool> binaryECIs;
|
|
450
|
+
ForEachECIBlock([&](ECI eci, int begin, int end) {
|
|
451
|
+
if (eci == ECI::Unknown)
|
|
452
|
+
eci = fallback;
|
|
453
|
+
binaryECIs.push_back((!IsText(eci)
|
|
454
|
+
|| (ToInt(eci) > 0 && ToInt(eci) < 28 && ToInt(eci) != 25
|
|
455
|
+
&& std::any_of(bytes.begin() + begin, bytes.begin() + end,
|
|
456
|
+
[](auto c) { return c < 0x20 && c != 0x9 && c != 0xa && c != 0xd; }))));
|
|
457
|
+
});
|
|
458
|
+
|
|
459
|
+
if (!Contains(binaryECIs, true))
|
|
460
|
+
return ContentType::Text;
|
|
461
|
+
if (!Contains(binaryECIs, false))
|
|
462
|
+
return ContentType::Binary;
|
|
463
|
+
|
|
464
|
+
return ContentType::Mixed;
|
|
465
|
+
#else
|
|
466
|
+
//TODO: replace by proper construction from encoded data from within zint
|
|
467
|
+
return ContentType::Text;
|
|
468
|
+
#endif
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
} // namespace ZXing
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2022 Axel Waggershauser
|
|
3
|
+
*/
|
|
4
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
|
|
6
|
+
#pragma once
|
|
7
|
+
|
|
8
|
+
#include "ByteArray.h"
|
|
9
|
+
#include "CharacterSet.h"
|
|
10
|
+
#include "ContentType.h"
|
|
11
|
+
#include "ECI.h"
|
|
12
|
+
#include "ReaderOptions.h"
|
|
13
|
+
#include "SymbologyIdentifier.h"
|
|
14
|
+
#include "Version.h"
|
|
15
|
+
#include "ZXAlgorithms.h"
|
|
16
|
+
|
|
17
|
+
#include <string>
|
|
18
|
+
#include <string_view>
|
|
19
|
+
#include <vector>
|
|
20
|
+
|
|
21
|
+
namespace ZXing {
|
|
22
|
+
|
|
23
|
+
class Content
|
|
24
|
+
{
|
|
25
|
+
template <typename FUNC>
|
|
26
|
+
void ForEachECIBlock(FUNC f) const;
|
|
27
|
+
|
|
28
|
+
void switchEncoding(ECI eci, bool isECI);
|
|
29
|
+
std::string render(bool withECI) const;
|
|
30
|
+
|
|
31
|
+
public:
|
|
32
|
+
struct Encoding
|
|
33
|
+
{
|
|
34
|
+
ECI eci;
|
|
35
|
+
int pos;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
ByteArray bytes;
|
|
39
|
+
std::vector<Encoding> encodings;
|
|
40
|
+
#if !defined(ZXING_READERS) && defined(ZXING_USE_ZINT)
|
|
41
|
+
std::vector<std::string> utf8Cache;
|
|
42
|
+
#endif
|
|
43
|
+
SymbologyIdentifier symbology;
|
|
44
|
+
CharacterSet defaultCharset = CharacterSet::Unknown;
|
|
45
|
+
bool hasECI = false;
|
|
46
|
+
|
|
47
|
+
Content() = default;
|
|
48
|
+
Content(ByteArray&& bytes, SymbologyIdentifier si, CharacterSet defaultCharset = CharacterSet::Unknown);
|
|
49
|
+
|
|
50
|
+
// make movable but not copyable
|
|
51
|
+
Content(const Content& other) = delete;
|
|
52
|
+
Content& operator=(const Content& other) = delete;
|
|
53
|
+
Content(Content&& other) = default;
|
|
54
|
+
Content& operator=(Content&& other) = default;
|
|
55
|
+
|
|
56
|
+
void switchEncoding(ECI eci) { switchEncoding(eci, true); }
|
|
57
|
+
void switchEncoding(CharacterSet cs);
|
|
58
|
+
|
|
59
|
+
void reserve(int count) { bytes.reserve(bytes.size() + count); }
|
|
60
|
+
|
|
61
|
+
void push_back(uint8_t val) { bytes.push_back(val); }
|
|
62
|
+
void push_back(int val) { bytes.push_back(narrow_cast<uint8_t>(val)); }
|
|
63
|
+
void append(std::string_view str) { bytes.insert(bytes.end(), str.begin(), str.end()); }
|
|
64
|
+
void append(ByteView bv) { bytes.insert(bytes.end(), bv.begin(), bv.end()); }
|
|
65
|
+
void append(const Content& other);
|
|
66
|
+
|
|
67
|
+
void erase(int pos, int n);
|
|
68
|
+
void insert(int pos, std::string_view str);
|
|
69
|
+
|
|
70
|
+
bool empty() const { return bytes.empty(); }
|
|
71
|
+
bool canProcess() const;
|
|
72
|
+
|
|
73
|
+
std::string text(TextMode mode) const;
|
|
74
|
+
std::wstring utfW() const; // utf16 or utf32 depending on the platform, i.e. on size_of(wchar_t)
|
|
75
|
+
std::string utf8() const { return render(false); }
|
|
76
|
+
|
|
77
|
+
ByteArray bytesECI() const;
|
|
78
|
+
CharacterSet guessEncoding() const;
|
|
79
|
+
ContentType type() const;
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
} // ZXing
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2026 Axel Waggershauser
|
|
3
|
+
*/
|
|
4
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
|
|
6
|
+
#pragma once
|
|
7
|
+
|
|
8
|
+
#include <string>
|
|
9
|
+
|
|
10
|
+
namespace ZXing {
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* @brief Provides a hint to the type of content encoded in a barcode, such as text, binary data, etc.
|
|
14
|
+
*/
|
|
15
|
+
enum class ContentType { Text, Binary, Mixed, GS1, ISO15434, UnknownECI };
|
|
16
|
+
|
|
17
|
+
std::string ToString(ContentType type);
|
|
18
|
+
|
|
19
|
+
} // ZXing
|