Bug 127233 - QR-code generator make non-correct QR for non latine phrase
Summary: QR-code generator make non-correct QR for non latine phrase
Status: VERIFIED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: LibreOffice (show other bugs)
Version:
(earliest affected)
6.4.0.0.alpha1+
Hardware: All All
: medium normal
Assignee: Julien Nabet
URL:
Whiteboard: target:6.4.0
Keywords: implementationError
Depends on:
Blocks: QR-code
  Show dependency treegraph
 
Reported: 2019-08-30 06:55 UTC by Roman Kuznetsov
Modified: 2019-09-03 06:40 UTC (History)
2 users (show)

See Also:
Crash report or crash signature:


Attachments
Example with QR-code (12.42 KB, application/vnd.oasis.opendocument.text)
2019-08-30 06:58 UTC, Roman Kuznetsov
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Roman Kuznetsov 2019-08-30 06:55:24 UTC
Description:
QR-code generator make non-correct QR for non latine phrase

Steps to Reproduce:
1. Open Writer
2. Select Insert->QR code
3. In URL/Text field type phrase "Я люблю космос" and press OK button
4. Try read QR code from screen with your smartphone's QR reader soft => I see only ? ????? ?????

If I try english phrase like "I like a Space" then my smartphone's QR reader shows me correct phrase

Actual Results:
I see only ? ????? ?????

Expected Results:
I should see correct russian phrase


Reproducible: Always


User Profile Reset: No



Additional Info:
Version: 6.4.0.0.alpha0+ (x86)
Build ID: a1a401acaafee0b1f154d368a247d74d61c62191
CPU threads: 4; OS: Windows 6.1; UI render: default; VCL: win; 
TinderBox: Win-x86@62-TDF, Branch:MASTER, Time: 2019-08-28_15:45:26
Locale: ru-RU (ru_RU); UI-Language: en-US
Calc: threaded
Comment 1 Roman Kuznetsov 2019-08-30 06:58:22 UTC
Created attachment 153741 [details]
Example with QR-code
Comment 2 Julien Nabet 2019-08-30 09:38:14 UTC
On Win10 with master sources updated yesterday, I could reproduce this.
Comment 3 Julien Nabet 2019-08-30 09:47:36 UTC
Shubham: I tested this patch:

diff --git a/cui/source/dialogs/QrCodeGenDialog.cxx b/cui/source/dialogs/QrCodeGenDialog.cxx
index 661d36678c07..7bd72ff0fc1c 100644
--- a/cui/source/dialogs/QrCodeGenDialog.cxx
+++ b/cui/source/dialogs/QrCodeGenDialog.cxx
@@ -259,7 +259,7 @@ OUString QrCodeGenDialog::GenerateQRCode(OUString aQRText, long aQRECC, int aQRB
     }

     //OuString to char* qrtext
-    OString o = OUStringToOString(aQRText, RTL_TEXTENCODING_ASCII_US);
+    OString o = OUStringToOString(aQRText, RTL_TEXTENCODING_UTF8);
     const char* qrtext = o.pData->buffer;

     //From Qr Code library.

it seemed ok to me but perhaps there would be some side effect.

Any thoughts?
I can submit it on gerrit after my day time job if you're ok or you can do it if you prefer.
Comment 4 Mike Kaganski 2019-08-30 12:14:34 UTC
(In reply to Julien Nabet from comment #3)
> Any thoughts?

Given that workdir/UnpackedTarball/qrcodegen/cpp/QrCode.hpp:73 has this for qrcodegen::QrCode::encodeText:

> 	/* 
> 	 * Returns a QR Code representing the given Unicode text string at the given error correction level.
> 	 * As a conservative upper bound, this function is guaranteed to succeed for strings that have 2953 or fewer
> 	 * UTF-8 code units (not Unicode code points) if the low error correction level is used. The smallest possible
> 	 * QR Code version is automatically chosen for the output. The ECC level of the result may be higher than
> 	 * the ecl argument if it can be done without increasing the version.
> 	 */

I suppose the change is perfectly correct; Julien please do submit it (it's your patch ;-))
Comment 5 Julien Nabet 2019-08-30 15:05:45 UTC
https://gerrit.libreoffice.org/#/c/78304/
Comment 6 Commit Notification 2019-08-30 19:42:59 UTC
Julien Nabet committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/+/8cecd48af5dbd290d06641b7feeb7c0969752d57%5E%21

tdf#127233: QR-code generator, use UTF-8 encoding

It will be available in 6.4.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 7 Roman Kuznetsov 2019-09-03 06:40:32 UTC
verified in

Version: 6.4.0.0.alpha0+ (x86)
Build ID: 1485bcc796dd8bd53762368ec4a1345ddb7cda72
CPU threads: 4; OS: Windows 6.1; UI render: default; VCL: win; 
TinderBox: Win-x86@62-TDF, Branch:MASTER, Time: 2019-09-02_10:30:21
Locale: ru-RU (ru_RU); UI-Language: en-US
Calc: threaded

Thanks Julien and Mike ;-)