Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2002-03-18
6
Medium Priority
?
420 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
Technology Partners: 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 800 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

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall‚Ķ
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

688 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