From: Jean on
Hello
I try to list file names containing unicode chars (cyrillic)
I use VC6, SDK

I have an Unicode project, I list the folder with FindFirstFileW and
FindNextFileW.
The files are listed, the WIN32_FIND_DATAW structure is filled.

I can't write the file names to a text file :-(
The code is as follow:

LPCWST folder=L"c:\unicode\*.*";
WIN32_FIND_DATAW wfind;
char fullname[_MAX_PATH];
FILE*pf=fopen("c:\\temp\\files.txt","wb");

handle=FinfFirstFileW(folder, & wfind);
do {
wcstombs(fullname, wfind.vFileName, _MAX_PATH);
fwrite(fullname, sizeof(char), strlen(fullame), pf);
} while(FindNextFileW(handle, &wfind);

All i get in the text file is . and ..

please help :-((

Jean


From: Ulrich Eckhardt on
Jean wrote:
> I try to list file names containing unicode chars (cyrillic)
> I use VC6, SDK

VC6 is > 10 years old and not supported generally...

> I have an Unicode project, I list the folder with FindFirstFileW and
> FindNextFileW.
> The files are listed, the WIN32_FIND_DATAW structure is filled.
>
> I can't write the file names to a text file :-(
[...]
> wcstombs(fullname, wfind.vFileName, _MAX_PATH);

1. Check the returnvalue.
2. Use WideCharToMultibyte() instead, using e.g. UTF-8 as encoding.

> fwrite(fullname, sizeof(char), strlen(fullame), pf);
^^^^^^^^^^^^

This is by definition 1, all sizes are in multiples of the size of a char.
Harmless, but just wanted to mention it.

Uli

--
Sator Laser GmbH
Geschäftsführer: Thorsten Föcking, Amtsgericht Hamburg HR B62 932

From: Jean on
>Use WideCharToMultibyte
Thank you Ulrich, it works fine :-)


>> VC6 is > 10 years old and not supported generally...
VC6 works very well on Win 95 -> Win 7 :-)

Jean

"Ulrich Eckhardt" <eckhardt(a)satorlaser.com> a �crit dans le message de news:
l76477-5gu.ln1(a)satorlaser.homedns.org...
> Jean wrote:
>> I try to list file names containing unicode chars (cyrillic)
>> I use VC6, SDK
>
> VC6 is > 10 years old and not supported generally...
>
>> I have an Unicode project, I list the folder with FindFirstFileW and
>> FindNextFileW.
>> The files are listed, the WIN32_FIND_DATAW structure is filled.
>>
>> I can't write the file names to a text file :-(
> [...]
>> wcstombs(fullname, wfind.vFileName, _MAX_PATH);
>
> 1. Check the returnvalue.
> 2. Use WideCharToMultibyte() instead, using e.g. UTF-8 as encoding.
>
>> fwrite(fullname, sizeof(char), strlen(fullame), pf);
> ^^^^^^^^^^^^
>
> This is by definition 1, all sizes are in multiples of the size of a char.
> Harmless, but just wanted to mention it.
>
> Uli
>
> --
> Sator Laser GmbH
> Gesch�ftsf�hrer: Thorsten F�cking, Amtsgericht Hamburg HR B62 932
>


From: r_z_aret on
On Tue, 16 Mar 2010 12:21:57 +0100, Ulrich Eckhardt
<eckhardt(a)satorlaser.com> wrote:

>Jean wrote:
>> I try to list file names containing unicode chars (cyrillic)
>> I use VC6, SDK
>
>VC6 is > 10 years old and not supported generally...

But it still works.

>

-----------------------------------------
To reply to me, remove the underscores (_) from my email address (and please indicate which newsgroup and message).

Robert E. Zaret, eMVP
PenFact, Inc.
20 Park Plaza, Suite 400
Boston, MA 02116
www.penfact.com
Useful reading (be sure to read its disclaimer first):
http://catb.org/~esr/faqs/smart-questions.html