Solved

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

Posted on 2002-03-18
6
393 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
  • 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
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 

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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
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 be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

813 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now