Solved

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

Posted on 2002-03-18
6
390 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
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
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 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.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

759 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

20 Experts available now in Live!

Get 1:1 Help Now