Solved

how to add indicator 'fffe' in the beginning of a unicode file

Posted on 2002-03-18
6
400 Views
Last Modified: 2008-02-26
hi
i am merging 4 unicode files in a single text file.
but after merging when i check the newly created file, the indicator 'FFFE' that shows, it is a unicode file is missed from the beginning.
can anyone help me , how to introduce this indicator at the beginnning of a newly created UNICODE file..
i am working in VC++;
thanx.
0
Comment
Question by:Ultpak
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 49

Expert Comment

by:DanRollins
ID: 6879316
What fn are you using to write the file?  With most standard fns, you need to insert the Byte Order Mark manually.

-- Dan
0
 

Author Comment

by:Ultpak
ID: 6881986
thanx for replying.
i am using fwopen to open the file or create a neww file.
and using fwput to write in the file from a buffer of type wchar.

0
 
LVL 49

Expert Comment

by:DanRollins
ID: 6882028
I can't find those functions in MSDN.  But assuming that fwput is equivallent to fputws, you will need to insert the FF FE manually as the first two bytes of the file.

-- Dan
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:Ultpak
ID: 6882163
thanx again
i do't remember exactly as i am not at work today
but these are the wide character functions to open and create a file. and to write in it.
okay these are _wfopen, and fputwc functions.
can you please tell me now how to write first two bytes as ff and fe.
what will be there character code to write, as i am writing in a file as a wide charater.
please
i will be so grateful to you.
yours
Ultoo
0
 
LVL 49

Accepted Solution

by:
DanRollins earned 200 total points
ID: 6882199
    wchar_t s[]= L"This is the text to write";
     wchar_t sByteOrderMark[]= L"\xfeff";

     FILE* pf= _wfopen(L"c:\\temp\\unicode.txt", L"wb" );

     fputws( sByteOrderMark, pf );
     fputws( s, pf );
     fclose( pf );

The fffe is put in reverse order as shown (\xfeff) because intel architechure places the low byte of a two-byte value first.

-- Dan

0
 

Author Comment

by:Ultpak
ID: 6884709
thanx a lot.
you did a lot for me.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question