Solved

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

Posted on 2002-03-18
6
405 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

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

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!

Question has a verified solution.

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

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
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 pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

615 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