ZXing: no need for deprecated utf-8 conversions anymore

With ZXing 2.0, the library directly supports utf8 std::string
parameters: https://github.com/zxing-cpp/zxing-cpp/releases/tag/v2.0.0

Fixes the warning:

 cui/source/dialogs/QrCodeGenDialog.cxx:161:72: warning: 'FromUtf8' is deprecated [-Wdeprecated-declarations]
  161 |     ZXing::BitMatrix bitmatrix = writer.encode(ZXing::TextUtfEncoding::FromUtf8(QRText), 0, 0);
      |                                                                        ^
 /usr/include/ZXing/TextUtfEncoding.h:17:3: note: 'FromUtf8' has been explicitly marked deprecated here
   17 | [[deprecated]] std::wstring FromUtf8(std::string_view utf8);
      |   ^

Change-Id: Ic0a65d4455dabea1a7a4e23f558e4158a0c3f39f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161182
Tested-by: Jenkins
Reviewed-by: Thorsten Behrens <thorsten.behrens@allotropia.de>
This commit is contained in:
Thorsten Behrens
2023-12-23 09:52:54 +01:00
parent 0ecedeea71
commit 14c4c07718
+4 -5
View File
@@ -19,6 +19,7 @@
#include <vcl/svapp.hxx>
#if ENABLE_ZXING
#include <ZXVersion.h>
#include <rtl/strbuf.hxx>
#ifdef __GNUC__
@@ -38,9 +39,7 @@
#include <BitMatrixIO.h>
#endif
#if __has_include(<Utf.h>)
#include <Utf.h>
#else
#if ZXING_VERSION_MAJOR < 2
#include <TextUtfEncoding.h>
#endif
@@ -153,8 +152,8 @@ OString GenerateQRCode(std::u16string_view aQRText, tools::Long aQRECC, int aQRB
ZXing::BarcodeFormat format = ZXing::BarcodeFormatFromString(GetBarCodeType(aQRType));
auto writer = ZXing::MultiFormatWriter(format).setMargin(aQRBorder).setEccLevel(bqrEcc);
writer.setEncoding(ZXing::CharacterSet::UTF8);
#if __has_include(<Utf.h>)
ZXing::BitMatrix bitmatrix = writer.encode(ZXing::FromUtf8(QRText), 0, 0);
#if ZXING_VERSION_MAJOR >= 2
ZXing::BitMatrix bitmatrix = writer.encode(QRText, 0, 0);
#else
ZXing::BitMatrix bitmatrix = writer.encode(ZXing::TextUtfEncoding::FromUtf8(QRText), 0, 0);
#endif