Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 4 commits into from
Jul 13, 2017
Merged

Conversation

ogoffart
Copy link
Contributor

@ogoffart ogoffart commented Jul 4, 2017

Replaces #5715

Should fix issues:

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

ckamm commented Jul 4, 2017

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
#else
dst = c_strdup(wstr);
QTextDecoder dec(QTextCodec::codecForLocale());
QString s = dec.toUnicode(wstr, qstrlen(wstr));
Copy link
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
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)

Copy link
Contributor

@dragotin dragotin left a comment

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
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
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
Copy link
Contributor

guruz commented Jul 14, 2017

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