Skip to content

csync: Use Qt for encoding conversion instead of iconv - #5875

Merged
ogoffart merged 4 commits into
masterfrom
encoding
Jul 13, 2017
Merged

ogoffart merged 4 commits into
masterfrom
encoding

Conversation

@ogoffart

@ogoffart ogoffart commented Jul 4, 2017 •

Copy link
Copy Markdown
Contributor

Replaces #5715

Should fix issues:

@ogoffart
ogoffart requested review from ckamm and guruz July 4, 2017 11:15
@ckamm

ckamm commented Jul 4, 2017

Copy link
Copy Markdown
Contributor

This looks good, in particular the dependency removal and being able to use Qt in csync.

I worry about testing a bit - if this introduces issues we'll only notice by seeing bad filenames on users' machines. We should run the encoding tests on all platforms (I assume you covered linux?), and maybe check how thorough they are.

We use iconv to normalize the string on mac. But the iconv version
on mac does not support full unicode.
So we will use Qt to normalize the string
ogoffart and others added 3 commits July 4, 2017 15:26
It's a C++ file so we will be able to use Qt from it
Issues:
 - #5661   On mac, iconv did not support all of unicode and some
           files with emoji in the filename could not be uploaded

 - #5719 , #5676  On linux, we will now support non utf-8 locale
Comment thread csync/src/std/c_utf8.cc
#else
dst = c_strdup(wstr);
QTextDecoder dec(QTextCodec::codecForLocale());
QString s = dec.toUnicode(wstr, qstrlen(wstr));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const QString s = .... ?

Tested on Linux and works, but might be an issue on MacOSX

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

's' can't be const for two reason: First, on mac, we update it with s = s.normalized(QString::NormalizationForm_C);
Second, we std::move it before calling toUtf8. This saves an allocation as there is an overload of toUtf8 which does the conversion in-place. (but does not work if s was const)

@dragotin dragotin left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

csync/tests/encoding_tests/check_encoding.c: still uses c_setup_iconv() on MacOSX, not sure if that is still available/necessary?

@ogoffart

Copy link
Copy Markdown
Contributor Author

Regarding the check_encoding.c, it is true that the #ifdef HAVE_ICONV will not be compiled and could be cleaned up. I just kept it because i did not want to change the test. It should anyway pass with or without iconv as the behavior should be the same. (except for the codepoints that were not understood by macos's iconv)

The CI is failiong for unrelated reason (it ran out of disk)

Any objection for merging this?

@ogoffart

Copy link
Copy Markdown
Contributor Author

@jturcotte quickly tested this patch on windows and did not notice regressions.

Since there are no objections, i'm merging now.

@ogoffart
ogoffart merged commit 7adcb76 into master Jul 13, 2017
@ogoffart
ogoffart deleted the encoding branch July 13, 2017 08:01
@guruz

guruz commented Jul 14, 2017

Copy link
Copy Markdown
Contributor

Some troubles with APFS see here: #5650
(But they appear unrelated to this PR..)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants