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,23 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2025 Axel Waggershauser
|
|
3
|
+
*/
|
|
4
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
|
|
6
|
+
#pragma once
|
|
7
|
+
|
|
8
|
+
#include "CharacterSet.h"
|
|
9
|
+
#include "ECI.h"
|
|
10
|
+
#include "Range.h"
|
|
11
|
+
|
|
12
|
+
#include <string>
|
|
13
|
+
|
|
14
|
+
namespace ZXing {
|
|
15
|
+
|
|
16
|
+
std::string BytesToUtf8(ByteView bytes, ECI eci);
|
|
17
|
+
|
|
18
|
+
inline std::string BytesToUtf8(ByteView bytes, CharacterSet cs)
|
|
19
|
+
{
|
|
20
|
+
return BytesToUtf8(bytes, ToECI(cs));
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
} // ZXing
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2016 Nu-book Inc.
|
|
3
|
+
*/
|
|
4
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
|
|
6
|
+
#include "TextEncoder.h"
|
|
7
|
+
|
|
8
|
+
#include "CharacterSet.h"
|
|
9
|
+
#include "ECI.h"
|
|
10
|
+
#include "Utf.h"
|
|
11
|
+
#include "ZXAlgorithms.h"
|
|
12
|
+
#include "Version.h"
|
|
13
|
+
|
|
14
|
+
#ifdef ZXING_USE_ZINT
|
|
15
|
+
#include <zint.h>
|
|
16
|
+
#else
|
|
17
|
+
#include "libzueci/zueci.h"
|
|
18
|
+
#endif
|
|
19
|
+
|
|
20
|
+
#include <stdexcept>
|
|
21
|
+
|
|
22
|
+
namespace ZXing {
|
|
23
|
+
|
|
24
|
+
void TextEncoder::GetBytes(const std::string& str, CharacterSet charset, std::string& bytes)
|
|
25
|
+
{
|
|
26
|
+
#if 0
|
|
27
|
+
bytes = str;
|
|
28
|
+
#else
|
|
29
|
+
int eci = ToInt(ToECI(charset));
|
|
30
|
+
const int str_len = narrow_cast<int>(str.length());
|
|
31
|
+
int eci_len;
|
|
32
|
+
|
|
33
|
+
if (eci == -1)
|
|
34
|
+
eci = 899; // Binary
|
|
35
|
+
|
|
36
|
+
bytes.clear();
|
|
37
|
+
|
|
38
|
+
#ifdef ZXING_USE_ZINT
|
|
39
|
+
int error_number = ZBarcode_Dest_Len_ECI(eci, reinterpret_cast<const unsigned char *>(str.data()), str_len, &eci_len);
|
|
40
|
+
if (error_number >= ZINT_ERROR) // Shouldn't happen
|
|
41
|
+
throw std::logic_error("Internal error `ZBarcode_Dest_Len_ECI()`");
|
|
42
|
+
|
|
43
|
+
bytes.resize(eci_len); // Sufficient but approximate length
|
|
44
|
+
|
|
45
|
+
error_number = ZBarcode_UTF8_To_ECI(eci,reinterpret_cast<const unsigned char *>(str.data()), str_len,
|
|
46
|
+
reinterpret_cast<unsigned char *>(bytes.data()), &eci_len);
|
|
47
|
+
if (error_number >= ZINT_ERROR) {
|
|
48
|
+
bytes.clear();
|
|
49
|
+
throw std::invalid_argument("Unexpected charcode");
|
|
50
|
+
}
|
|
51
|
+
#else
|
|
52
|
+
int error_number = zueci_dest_len_eci(eci, reinterpret_cast<const unsigned char *>(str.data()), str_len, &eci_len);
|
|
53
|
+
if (error_number >= ZUECI_ERROR) // Shouldn't happen
|
|
54
|
+
throw std::logic_error("Internal error `zueci_dest_len_eci()`");
|
|
55
|
+
|
|
56
|
+
bytes.resize(eci_len); // Sufficient but approximate length
|
|
57
|
+
|
|
58
|
+
error_number = zueci_utf8_to_eci(eci, reinterpret_cast<const unsigned char *>(str.data()), str_len,
|
|
59
|
+
reinterpret_cast<unsigned char *>(bytes.data()), &eci_len);
|
|
60
|
+
if (error_number >= ZUECI_ERROR) {
|
|
61
|
+
bytes.clear();
|
|
62
|
+
throw std::invalid_argument("Unexpected charcode");
|
|
63
|
+
}
|
|
64
|
+
#endif // ZXING_USE_ZINT
|
|
65
|
+
|
|
66
|
+
bytes.resize(eci_len); // Actual length
|
|
67
|
+
#endif
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
void TextEncoder::GetBytes(const std::wstring& str, CharacterSet charset, std::string& bytes)
|
|
71
|
+
{
|
|
72
|
+
GetBytes(ToUtf8(str), charset, bytes);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
} // ZXing
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2016 Nu-book Inc.
|
|
3
|
+
*/
|
|
4
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
|
|
6
|
+
#pragma once
|
|
7
|
+
|
|
8
|
+
#include "CharacterSet.h"
|
|
9
|
+
|
|
10
|
+
#include <string>
|
|
11
|
+
|
|
12
|
+
namespace ZXing {
|
|
13
|
+
|
|
14
|
+
class TextEncoder
|
|
15
|
+
{
|
|
16
|
+
static void GetBytes(const std::string& str, CharacterSet charset, std::string& bytes);
|
|
17
|
+
static void GetBytes(const std::wstring& str, CharacterSet charset, std::string& bytes);
|
|
18
|
+
public:
|
|
19
|
+
static std::string FromUnicode(const std::string& str, CharacterSet charset) {
|
|
20
|
+
std::string r;
|
|
21
|
+
GetBytes(str, charset, r);
|
|
22
|
+
return r;
|
|
23
|
+
}
|
|
24
|
+
static std::string FromUnicode(const std::wstring& str, CharacterSet charset) {
|
|
25
|
+
std::string r;
|
|
26
|
+
GetBytes(str, charset, r);
|
|
27
|
+
return r;
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
} // ZXing
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2020 Axel Waggershauser
|
|
3
|
+
*/
|
|
4
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
|
|
6
|
+
#pragma once
|
|
7
|
+
|
|
8
|
+
#include "BinaryBitmap.h"
|
|
9
|
+
#include "BitMatrix.h"
|
|
10
|
+
|
|
11
|
+
#include <cstdint>
|
|
12
|
+
|
|
13
|
+
namespace ZXing {
|
|
14
|
+
|
|
15
|
+
class ThresholdBinarizer : public BinaryBitmap
|
|
16
|
+
{
|
|
17
|
+
const uint8_t _threshold = 0;
|
|
18
|
+
|
|
19
|
+
public:
|
|
20
|
+
ThresholdBinarizer(const ImageView& buffer, uint8_t threshold = 128) : BinaryBitmap(buffer), _threshold(threshold) {}
|
|
21
|
+
|
|
22
|
+
bool getPatternRow(int row, int rotation, PatternRow& res) const override
|
|
23
|
+
{
|
|
24
|
+
auto buffer = _buffer.rotated(rotation);
|
|
25
|
+
|
|
26
|
+
const int stride = buffer.pixStride();
|
|
27
|
+
const uint8_t* begin = buffer.data(0, row) + GreenIndex(buffer.format());
|
|
28
|
+
const uint8_t* end = begin + buffer.width() * stride;
|
|
29
|
+
|
|
30
|
+
auto* lastPos = begin;
|
|
31
|
+
bool lastVal = false;
|
|
32
|
+
|
|
33
|
+
res.clear();
|
|
34
|
+
|
|
35
|
+
for (const uint8_t* p = begin; p != end; p += stride) {
|
|
36
|
+
bool val = *p <= _threshold;
|
|
37
|
+
if (val != lastVal) {
|
|
38
|
+
res.push_back(narrow_cast<PatternRow::value_type>((p - lastPos) / stride));
|
|
39
|
+
lastVal = val;
|
|
40
|
+
lastPos = p;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
res.push_back(narrow_cast<PatternRow::value_type>((end - lastPos) / stride));
|
|
45
|
+
|
|
46
|
+
if (*(end - stride) <= _threshold)
|
|
47
|
+
res.push_back(0); // last value is number of white pixels, here 0
|
|
48
|
+
|
|
49
|
+
return true;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
std::shared_ptr<const BitMatrix> getBlackMatrix() const override
|
|
53
|
+
{
|
|
54
|
+
return std::make_shared<const BitMatrix>(binarize(_threshold));
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
} // ZXing
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2020 Axel Waggershauser
|
|
3
|
+
*/
|
|
4
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
|
|
6
|
+
#pragma once
|
|
7
|
+
|
|
8
|
+
#include "Matrix.h"
|
|
9
|
+
|
|
10
|
+
#include <cstdint>
|
|
11
|
+
|
|
12
|
+
namespace ZXing {
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* @brief Represent a tri-state value false/true/empty
|
|
16
|
+
*/
|
|
17
|
+
class Trit
|
|
18
|
+
{
|
|
19
|
+
public:
|
|
20
|
+
enum value_t : uint8_t {false_v, true_v, empty_v} value = empty_v;
|
|
21
|
+
Trit() = default;
|
|
22
|
+
Trit(bool v) : value(static_cast<value_t>(v)) {}
|
|
23
|
+
operator bool() const { return value == true_v; }
|
|
24
|
+
bool isEmpty() const { return value == empty_v; }
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
using TritMatrix = Matrix<Trit>;
|
|
28
|
+
|
|
29
|
+
} // ZXing
|
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2016 Nu-book Inc.
|
|
3
|
+
* Copyright 2021 gitlost
|
|
4
|
+
* Copyright 2022 Axel Waggershauser
|
|
5
|
+
*/
|
|
6
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
7
|
+
|
|
8
|
+
#include "Utf.h"
|
|
9
|
+
|
|
10
|
+
#include "ZXTestSupport.h"
|
|
11
|
+
#include "ZXAlgorithms.h"
|
|
12
|
+
|
|
13
|
+
#include <iomanip>
|
|
14
|
+
#include <cstdint>
|
|
15
|
+
#include <sstream>
|
|
16
|
+
#include <string_view>
|
|
17
|
+
|
|
18
|
+
using utf8_t = std::u8string_view;
|
|
19
|
+
|
|
20
|
+
namespace ZXing {
|
|
21
|
+
|
|
22
|
+
using state_t = uint8_t;
|
|
23
|
+
constexpr state_t kAccepted = 0;
|
|
24
|
+
constexpr state_t kRejected [[maybe_unused]] = 12;
|
|
25
|
+
|
|
26
|
+
inline char32_t Utf8Decode(char8_t byte, state_t& state, char32_t& codep)
|
|
27
|
+
{
|
|
28
|
+
// Copyright (c) 2008-2009 Bjoern Hoehrmann <bjoern@hoehrmann.de>
|
|
29
|
+
// See http://bjoern.hoehrmann.de/utf-8/decoder/dfa/ for details.
|
|
30
|
+
static constexpr const state_t kUtf8Data[] = {
|
|
31
|
+
/* The first part of the table maps bytes to character classes that
|
|
32
|
+
* reduce the size of the transition table and create bitmasks. */
|
|
33
|
+
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
34
|
+
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
35
|
+
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
36
|
+
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
37
|
+
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,
|
|
38
|
+
7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
|
|
39
|
+
8,8,2,2,2,2,2,2,2,2,2,2,2,2,2,2, 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
|
|
40
|
+
10,3,3,3,3,3,3,3,3,3,3,3,3,4,3,3, 11,6,6,6,5,8,8,8,8,8,8,8,8,8,8,8,
|
|
41
|
+
|
|
42
|
+
/* The second part is a transition table that maps a combination
|
|
43
|
+
* of a state of the automaton and a character class to a state. */
|
|
44
|
+
0,12,24,36,60,96,84,12,12,12,48,72, 12,12,12,12,12,12,12,12,12,12,12,12,
|
|
45
|
+
12, 0,12,12,12,12,12, 0,12, 0,12,12, 12,24,12,12,12,12,12,24,12,24,12,12,
|
|
46
|
+
12,12,12,12,12,12,12,24,12,12,12,12, 12,24,12,12,12,12,12,12,12,24,12,12,
|
|
47
|
+
12,12,12,12,12,12,12,36,12,36,12,12, 12,36,12,12,12,12,12,36,12,36,12,12,
|
|
48
|
+
12,36,12,12,12,12,12,12,12,12,12,12,
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
state_t type = kUtf8Data[byte];
|
|
52
|
+
codep = (state != kAccepted) ? (byte & 0x3fu) | (codep << 6) : (0xff >> type) & (byte);
|
|
53
|
+
state = kUtf8Data[256 + state + type];
|
|
54
|
+
return state;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
static_assert(sizeof(wchar_t) == 4 || sizeof(wchar_t) == 2, "wchar_t needs to be 2 or 4 bytes wide");
|
|
58
|
+
|
|
59
|
+
inline bool IsUtf16SurrogatePair(std::wstring_view str)
|
|
60
|
+
{
|
|
61
|
+
return sizeof(wchar_t) == 2 && str.size() >= 2 && (str[0] & 0xfc00) == 0xd800 && (str[1] & 0xfc00) == 0xdc00;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
inline char32_t Utf32FromUtf16Surrogates(std::wstring_view str)
|
|
65
|
+
{
|
|
66
|
+
return (static_cast<char32_t>(str[0]) << 10) + str[1] - 0x35fdc00;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
static size_t Utf8CountCodePoints(utf8_t utf8)
|
|
70
|
+
{
|
|
71
|
+
size_t count = 0;
|
|
72
|
+
|
|
73
|
+
for (size_t i = 0; i < utf8.size();) {
|
|
74
|
+
if (utf8[i] < 128) {
|
|
75
|
+
++i;
|
|
76
|
+
} else {
|
|
77
|
+
switch (utf8[i] & 0xf0) {
|
|
78
|
+
case 0xc0: [[fallthrough]];
|
|
79
|
+
case 0xd0: i += 2; break;
|
|
80
|
+
case 0xe0: i += 3; break;
|
|
81
|
+
case 0xf0: i += 4; break;
|
|
82
|
+
default: // we are in middle of a sequence
|
|
83
|
+
++i;
|
|
84
|
+
while (i < utf8.size() && (utf8[i] & 0xc0) == 0x80)
|
|
85
|
+
++i;
|
|
86
|
+
break;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
++count;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
return count;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
static void AppendFromUtf8(utf8_t utf8, std::wstring& buffer)
|
|
96
|
+
{
|
|
97
|
+
buffer.reserve(buffer.size() + Utf8CountCodePoints(utf8));
|
|
98
|
+
|
|
99
|
+
char32_t codePoint = 0;
|
|
100
|
+
state_t state = kAccepted;
|
|
101
|
+
|
|
102
|
+
for (auto b : utf8) {
|
|
103
|
+
if (Utf8Decode(b, state, codePoint) != kAccepted)
|
|
104
|
+
continue;
|
|
105
|
+
|
|
106
|
+
if (sizeof(wchar_t) == 2 && codePoint > 0xffff) { // surrogate pair
|
|
107
|
+
buffer.push_back(narrow_cast<wchar_t>(0xd7c0 + (codePoint >> 10)));
|
|
108
|
+
buffer.push_back(narrow_cast<wchar_t>(0xdc00 + (codePoint & 0x3ff)));
|
|
109
|
+
} else {
|
|
110
|
+
buffer.push_back(narrow_cast<wchar_t>(codePoint));
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
bool IsValidUtf8(ByteView bytes)
|
|
116
|
+
{
|
|
117
|
+
state_t state = kAccepted;
|
|
118
|
+
char32_t codepoint = 0;
|
|
119
|
+
for (int value : bytes) {
|
|
120
|
+
Utf8Decode(value, state, codepoint);
|
|
121
|
+
if (state == kRejected)
|
|
122
|
+
return false;
|
|
123
|
+
}
|
|
124
|
+
return state == kAccepted;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
std::wstring FromUtf8(std::string_view utf8)
|
|
128
|
+
{
|
|
129
|
+
std::wstring str;
|
|
130
|
+
AppendFromUtf8({reinterpret_cast<const char8_t*>(utf8.data()), utf8.size()}, str);
|
|
131
|
+
return str;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
std::wstring FromUtf8(std::u8string_view utf8)
|
|
135
|
+
{
|
|
136
|
+
std::wstring str;
|
|
137
|
+
AppendFromUtf8(utf8, str);
|
|
138
|
+
return str;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
// Count the number of bytes required to store given code points in UTF-8.
|
|
142
|
+
static size_t Utf8CountBytes(std::wstring_view str)
|
|
143
|
+
{
|
|
144
|
+
int result = 0;
|
|
145
|
+
for (; str.size(); str.remove_prefix(1)) {
|
|
146
|
+
if (str.front() < 0x80)
|
|
147
|
+
result += 1;
|
|
148
|
+
else if (str.front() < 0x800)
|
|
149
|
+
result += 2;
|
|
150
|
+
else if (sizeof(wchar_t) == 4) {
|
|
151
|
+
if (str.front() < 0x10000)
|
|
152
|
+
result += 3;
|
|
153
|
+
else
|
|
154
|
+
result += 4;
|
|
155
|
+
} else {
|
|
156
|
+
if (IsUtf16SurrogatePair(str)) {
|
|
157
|
+
result += 4;
|
|
158
|
+
str.remove_prefix(1);
|
|
159
|
+
} else
|
|
160
|
+
result += 3;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
return result;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
ZXING_EXPORT_TEST_ONLY
|
|
167
|
+
int Utf32ToUtf8(char32_t utf32, char* out)
|
|
168
|
+
{
|
|
169
|
+
if (utf32 < 0x80) {
|
|
170
|
+
*out++ = narrow_cast<char8_t>(utf32);
|
|
171
|
+
return 1;
|
|
172
|
+
}
|
|
173
|
+
if (utf32 < 0x800) {
|
|
174
|
+
*out++ = narrow_cast<char8_t>((utf32 >> 6) | 0xc0);
|
|
175
|
+
*out++ = narrow_cast<char8_t>((utf32 & 0x3f) | 0x80);
|
|
176
|
+
return 2;
|
|
177
|
+
}
|
|
178
|
+
if (utf32 < 0x10000) {
|
|
179
|
+
*out++ = narrow_cast<char8_t>((utf32 >> 12) | 0xe0);
|
|
180
|
+
*out++ = narrow_cast<char8_t>(((utf32 >> 6) & 0x3f) | 0x80);
|
|
181
|
+
*out++ = narrow_cast<char8_t>((utf32 & 0x3f) | 0x80);
|
|
182
|
+
return 3;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
*out++ = narrow_cast<char8_t>((utf32 >> 18) | 0xf0);
|
|
186
|
+
*out++ = narrow_cast<char8_t>(((utf32 >> 12) & 0x3f) | 0x80);
|
|
187
|
+
*out++ = narrow_cast<char8_t>(((utf32 >> 6) & 0x3f) | 0x80);
|
|
188
|
+
*out++ = narrow_cast<char8_t>((utf32 & 0x3f) | 0x80);
|
|
189
|
+
return 4;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
static void AppendToUtf8(std::wstring_view str, std::string& utf8)
|
|
193
|
+
{
|
|
194
|
+
utf8.reserve(utf8.size() + Utf8CountBytes(str));
|
|
195
|
+
|
|
196
|
+
char buffer[4];
|
|
197
|
+
for (; str.size(); str.remove_prefix(1))
|
|
198
|
+
{
|
|
199
|
+
uint32_t cp;
|
|
200
|
+
if (IsUtf16SurrogatePair(str)) {
|
|
201
|
+
cp = Utf32FromUtf16Surrogates(str);
|
|
202
|
+
str.remove_prefix(1);
|
|
203
|
+
} else
|
|
204
|
+
cp = str.front();
|
|
205
|
+
|
|
206
|
+
auto bufLength = Utf32ToUtf8(cp, buffer);
|
|
207
|
+
utf8.append(buffer, bufLength);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
std::string ToUtf8(std::wstring_view str)
|
|
212
|
+
{
|
|
213
|
+
std::string utf8;
|
|
214
|
+
AppendToUtf8(str, utf8);
|
|
215
|
+
return utf8;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
static bool iswgraph(wchar_t wc)
|
|
219
|
+
{
|
|
220
|
+
/* Consider all legal codepoints as graphical except for:
|
|
221
|
+
* - whitespace
|
|
222
|
+
* - C0 and C1 control characters
|
|
223
|
+
* - U+2028 and U+2029 (line/para break)
|
|
224
|
+
* - U+FFF9 through U+FFFB (interlinear annotation controls)
|
|
225
|
+
* The following code is based on libmusls implementation */
|
|
226
|
+
|
|
227
|
+
if (wc == ' ' || (unsigned)wc - '\t' < 5)
|
|
228
|
+
return false;
|
|
229
|
+
if (wc < 0xff)
|
|
230
|
+
return ((wc + 1) & 0x7f) >= 0x21;
|
|
231
|
+
if (wc < 0x2028 || wc - 0x202a < 0xd800 - 0x202a || wc - 0xe000 < 0xfff9 - 0xe000)
|
|
232
|
+
return true;
|
|
233
|
+
if (wc - 0xfffc > 0x10ffff - 0xfffc || (wc & 0xfffe) == 0xfffe)
|
|
234
|
+
return false;
|
|
235
|
+
return true;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
std::wstring EscapeNonGraphical(std::wstring_view str)
|
|
239
|
+
{
|
|
240
|
+
static const char* const ascii_nongraphs[33] = {
|
|
241
|
+
"NUL", "SOH", "STX", "ETX", "EOT", "ENQ", "ACK", "BEL",
|
|
242
|
+
"BS", "HT", "LF", "VT", "FF", "CR", "SO", "SI",
|
|
243
|
+
"DLE", "DC1", "DC2", "DC3", "DC4", "NAK", "SYN", "ETB",
|
|
244
|
+
"CAN", "EM", "SUB", "ESC", "FS", "GS", "RS", "US",
|
|
245
|
+
"DEL",
|
|
246
|
+
};
|
|
247
|
+
|
|
248
|
+
std::wostringstream ws;
|
|
249
|
+
ws.fill(L'0');
|
|
250
|
+
|
|
251
|
+
for (; str.size(); str.remove_prefix(1)) {
|
|
252
|
+
wchar_t wc = str.front();
|
|
253
|
+
if (wc < 32 || wc == 127) // Non-graphical ASCII, excluding space
|
|
254
|
+
ws << "<" << ascii_nongraphs[wc == 127 ? 32 : wc] << ">";
|
|
255
|
+
else if (wc < 128) // ASCII
|
|
256
|
+
ws << wc;
|
|
257
|
+
else if (IsUtf16SurrogatePair(str)) {
|
|
258
|
+
ws.write(str.data(), 2);
|
|
259
|
+
str.remove_prefix(1);
|
|
260
|
+
}
|
|
261
|
+
// Exclude unpaired surrogates and NO-BREAK spaces NBSP and NUMSP
|
|
262
|
+
else if ((wc < 0xd800 || wc >= 0xe000) && (iswgraph(wc) && wc != 0xA0 && wc != 0x2007 && wc != 0x2000 && wc != 0xfffd))
|
|
263
|
+
ws << wc;
|
|
264
|
+
else // Non-graphical Unicode
|
|
265
|
+
ws << "<U+" << std::setw(wc < 256 ? 2 : 4) << std::uppercase << std::hex << static_cast<uint32_t>(wc) << ">";
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
return ws.str();
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
std::string EscapeNonGraphical(std::string_view utf8)
|
|
272
|
+
{
|
|
273
|
+
return ToUtf8(EscapeNonGraphical(FromUtf8(utf8)));
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
} // namespace ZXing
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2022 Axel Waggershauser
|
|
3
|
+
*/
|
|
4
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
|
|
6
|
+
#pragma once
|
|
7
|
+
|
|
8
|
+
#include "Range.h"
|
|
9
|
+
|
|
10
|
+
#include <string>
|
|
11
|
+
#include <string_view>
|
|
12
|
+
|
|
13
|
+
namespace ZXing {
|
|
14
|
+
|
|
15
|
+
bool IsValidUtf8(ByteView bytes);
|
|
16
|
+
|
|
17
|
+
std::string ToUtf8(std::wstring_view str);
|
|
18
|
+
std::wstring FromUtf8(std::string_view utf8);
|
|
19
|
+
#ifdef __cpp_lib_char8_t
|
|
20
|
+
std::wstring FromUtf8(std::u8string_view utf8);
|
|
21
|
+
#endif
|
|
22
|
+
|
|
23
|
+
std::wstring EscapeNonGraphical(std::wstring_view str);
|
|
24
|
+
std::string EscapeNonGraphical(std::string_view utf8);
|
|
25
|
+
|
|
26
|
+
} // namespace ZXing
|