[delphizip] Re: error when reading a zip file in another PC

  • From: "Edwin" <mindvisualizer@xxxxxxxxx>
  • To: "delphizip@xxxxxxxxxxxxx" <delphizip@xxxxxxxxxxxxx>, "delphizip@xxxxxxxxxxxxx" <delphizip@xxxxxxxxxxxxx>
  • Date: Tue, 24 Jul 2007 15:35:05 +0800

Hi James and Peters,
The steps that the program opens the file:
1. Use TTntOpenDialog to get the file name in WideString, the file is a shared 
file in another PC that have different codepage.
2. Call Tntsystem.WideStringToStringEx(aFileName, DefaultSystemCodePage) to 
convert the widestring to string,
3. WideStringToStringEx internally calls WideCharToMultiByte, the source code:
//------------------------------------------------------------------
//source code
function WideStringToStringEx(const WS: WideString; CodePage: Cardinal): 
AnsiString;
var
  InputLength,
  OutputLength: Integer;
begin
  if CodePage = CP_UTF7 then
    Result := WideStringToUTF7(WS) // CP_UTF7 not supported on Windows 95
  else if CodePage = CP_UTF8 then
    Result := WideStringToUTF8(WS) // CP_UTF8 not supported on Windows 95
  else begin
    InputLength := Length(WS);
    OutputLength := WideCharToMultiByte(CodePage, 0, PWideChar(WS), 
InputLength, nil, 0, nil, nil);
    SetLength(Result, OutputLength);
    WideCharToMultiByte(CodePage, 0, PWideChar(WS), InputLength, 
PAnsiChar(Result), OutputLength, nil, nil);
  end;
end;
//end source code
//------------------------------------------------------------------


Is the parameter DefaultSystemCodePage caused the problem? 

But windows Explorer can copy the file, How can I solve the problem in Delphi? 
Thanks.




Best Regards,
Edwin
http://www.innovationgear.com
MindVisualizer -- Productive Visual Mind Mapping Software 
2007-07-24



Sender£º James Turner
Sent£º 2007-07-11 17:32:40
Recipient£º delphizip@xxxxxxxxxxxxx
CC£º 
Subject£º [delphizip] Re: error when reading a zip file in another PC

Using the short filename **might** work since it probably has only ascii 
characters (never checked this).

Are you using standard Delphi conversions or working with 
MultibyteToWideChar and WideCharToMultibyte directly?

If you use the style ES_OEMCONVERT in any editboxes, this might generate 
a conversion problem (never studied this).

-- James Turner

Edwin wrote:
> Do you mean call GetShortPathName before setting the value of the ZipFileName 
> property? The path name and file name that the user reported did not exceed 
> the max. 255 characters.
> BTW, since I use WideString as much as I can in the program, the path name is 
> converted from WideString to string before assigning to the property 
> TZipMaster.ZipFileName, using the routines in the TNT Controls package, I'm 
> not sure is there error in the conversion....
>
>
>
>
> Best Regards,
> Edwin
> http://www.innovationgear.com
> MindVisualizer -- Productive Visual Mind Mapping Software 
> 2007-07-11
>
>
>
> Sender£º James Turner
> Sent£º 2007-07-09 19:16:49
> Recipient£º delphizip@xxxxxxxxxxxxx
> CC£º 
> Subject£º [delphizip] Re: error when reading a zip file in another PC
>
> It's just a guess, but perhaps using the short filename would help.
>
> This can be found using the API function GetShortPathName. On some 
> versions of Windows, it can be found from the property sheet.
>
> -- James Turner
>
> RPeters wrote:
>   
> > I would say it is quite likely.
> > My understanding is that the UNC 'share name' still follows the old
> > restricted character rules - if I am wrong I will quite a bit of code to
> > adapt.
> >
> > I doubt that 1.79 (or earlier) is very friendly with MBCS characters either.
> > If you are using 1.79 you could have it generate a log file (put an
> > appropriate ini file in the same folder as the dll).
> > - Russell Peters
> >   
> >     
> > > -----Original Message-----
> > > From: delphizip-bounce@xxxxxxxxxxxxx [mailto:delphizip-
> > > bounce@xxxxxxxxxxxxx] On Behalf Of Edwin
> > > Sent: Monday, 9 July 2007 6:54 PM
> > > To: delphizip@xxxxxxxxxxxxx
> > > Subject: [delphizip] error when reading a zip file in another PC
> > >
> > > Dear sir/Madam,
> > >
> > > Error when reading a zip file which is located in another PC and the
> > > UNI path reads like \\pc1\folder1\my_file.zip, where folder1 contains
> > > Chinese characters.  This error is reported by one of my users and I
> > > cannot reproduce this error in my office. Any tips would be
> > > appreciated.
> > >
> > > BTW, Is the archive of this list available?
> > > --------------
> > > Best Regards,
> > > Edwin
> > > http://www.innovationgear.com
> > > MindVisualizer -- Productive Visual Mind Mapping Software
> > > 2007-07-09
> > >
> > > -----------
> > > To unsubscribe from this list, send an empty e-mail
> > > message to:
> > >   delphizip-request@xxxxxxxxxxxxx
> > > and put the word unsubscribe in the subject.
> > >
> > > __________ NOD32 2384 (20070708) Information __________
> > >
> > > This message was checked by NOD32 antivirus system.
> > > http://www.eset.com
> > >     
> > >       
> > -----------
> > To unsubscribe from this list, send an empty e-mail 
> > message to:
> >   delphizip-request@xxxxxxxxxxxxx 
> > and put the word unsubscribe in the subject.
> >
> >   
> >     
> -----------
> To unsubscribe from this list, send an empty e-mail 
> message to:
>   delphizip-request@xxxxxxxxxxxxx 
> and put the word unsubscribe in the subject.
>
>
> -----------
> To unsubscribe from this list, send an empty e-mail 
> message to:
>   delphizip-request@xxxxxxxxxxxxx 
> and put the word unsubscribe in the subject.
>
>   
-----------
To unsubscribe from this list, send an empty e-mail 
message to:
  delphizip-request@xxxxxxxxxxxxx 
and put the word unsubscribe in the subject.


-----------
To unsubscribe from this list, send an empty e-mail 
message to:
  delphizip-request@xxxxxxxxxxxxx 
and put the word unsubscribe in the subject.

Other related posts: