login about faq

ifdef Q_OS_WIN // Windows

define UUU(x) (LPCWSTR)x.unicode()

define SSS(x) QString((QChar*)x)

else // Mac and Linux

define UUU(x) (wchar_t*)x.toStdWString().c_str()

define SSS(x) QString::fromWCharArray(x)


DOCUMENT TO QString::toStdWString() http://doc.qt.io/qt-5/qstring.html#toStdWString

MyTool.h: CkZipW* m_zip;

void MyTool::Mytool { m_zip = new CkZipW(); bool success = m_zip->UnlockComponent(ZIP_CODE); }

bool MyTool::ZipAES(QString strSrcFile, QString strPasswd) { const QFileInfo fi = QFileInfo(strSrcFile); QString strFileName = fi.fileName()+".zip"; QString strDestFile = "/dev/"+strFileName; // or "c:/dev/"

bool success1 = m_zip->NewZip(UUU(strDestFile));


bool success2 = m_zip->AppendOneFileOrDir(UUU(strSrcFile), false);
if (success2 != true) {
    qDebug() << strSrcFile;

bool success3 = m_zip->WriteZipAndClose();

return success1 && success2 && success3;


I Use MyTool tool; tool.ZipAES("c:/test.txt", "00000");

QString is always Unicode with 16 bit in all platforms. But Chilkat always use wchar_t which has different bits. So I have to transform QString to wchar_t.

The above code works well in windows. And it works well also in Mac (Zip and UnZip). But in Mac, the real password is not 00000 (I copy the zip file to windows and try to use winrar to decompress it, but it fail), it is other something. Windows has not this problem. Could you tell me what's wrong with my code above and what is the real password final if possible. Thanks!

I use C++/Mingw/Clang, CkZipW in Windows, CkZipW in Mac , Qt5.6.

asked May 31 '16 at 06:38

muggle222's gravatar image


edited May 31 '16 at 09:09

Thanks, I'm looking into it.. -Matt


answered May 31 '16 at 17:18

chilkat's gravatar image

chilkat ♦♦

Please try this new build for Mac OS X C++:


This build adds a full set of C++ classes that end in "U" instead of "W". For example: the class CkZipU where the header file is CkZipU.h The "U" classes use "uint16_t " instead of "wchar_t ". These classes have existed for a long time internal to Chilkat, but have never been exposed. From this point onward, starting with the next version, they will be included in the Linux, Mac OS X, and Mingw libs. Everything's the same as the wchar_t classes, except the class name ends in "U" and "uint16_t" is used instead of "wchar_t".

I'm doing the Mingw builds now, and will post when ready.

Also, these pre-release include the CkRestU class, and all other classes marked as "Coming soon".


answered May 31 '16 at 19:00

chilkat's gravatar image

chilkat ♦♦

OK, I tested "U" in Mac, now the password is correct "00000".

But I don't understand, why not correct this problem in W version. Because every function works well as I expect, except the function put_EncryptPassword.Otherwise nobody knows the correct password, event it can still work.

Let me continue to test in Windows with U version, so I can keep always the unique code in all platforms.


answered Jun 01 '16 at 06:57

muggle222's gravatar image


Any news for this bug in "W" version? And the problem of callback of SFTP? I am eager to wait for your corrections to these two bugs.



answered Jun 10 '16 at 14:35

muggle222's gravatar image


Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or __italic__
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported



Asked: May 31 '16 at 06:38

Seen: 387 times

Last updated: Jun 10 '16 at 14:35

powered by OSQA