i'm trying compress files non ascii file names minizip. if file troublesome file name, name @ least 1 charactar not in ascii compressed, name of file in archive messed up. red how convert minizip wrapper unicode? , changed source code flag 11 set true made no different.
an example illustrate problem:
the file 中文 named s+í¦vt in zip archive.
or in hex:
\x53\x2b\xa1\xb5\xfb\xe7 \x53\x2b\xed\xa6\x76\x74 first 2 hexs same not last four. \x53\x2b\xed\xa6\x76\x74 s+í¦vt in window 1252
the file name in program hard coded \x53\x2b\xa1\xb5\xfb\xe7(中文) remove risk input incorrect.
files ascii characters in file name named should in zip archive. on ground name of file in zip archive longer the original file name , made assumption encoding utf-8 used.
since symbols in computers in fact binary strings, hope 1 hex string output correct file name. problem here not know how file names encoded in zip archive.
does have clue how translation hex/utf-8to correct 1 , encoding used?
i think zip archive used os standard encoding in case windows-1252.
const char kchinesesampletext[] = "\x53\x2b\xa1\xb5\xfb\xe7"; if ( open_file( zipf, kchinesesampletext ) ) { //write file } bool open_file( const zipfile zipfile, const char* filename) { zip_fileinfo zfi; int status = zipopennewfileinzip( zipfile, filename , null, &zfi, null, 0, null, 0, z_deflated, z_default_compression ); if( status != zip_ok ) { zipclose( zipfile, null ); return false; } true; }
first of all, consider taking file name. normally, winapi functions have ansi , unicode version, identified suffix 'a' or 'w', respectively. can't see because it's compiler work. can force ansi attaching 'a' function, findnextfilea (well, think listing folder findfirstfile).
if can't identify wichever source format, call istextunicode(filename, filenamesize, null) check if file name in unicode format. if is, call widechartomultibyte(cp_oemcp, 0, filename, filenamesize, ansifilename, ansifilenamesize, 0, null).
hope helps , sorry bad english.
Comments
Post a Comment