473,385 Members | 1,372 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

fprintf() not saving a file in utf8

110 100+
fprintf() is saving a file in utf8 but Bom for utf8 is missing..
Can we save a file with utf8 BOM? for eg.
I want to save a file with BOM .. EF BB BF in the beginning..
is it possible to do that in C++?

Thnx in advance..
Xoinki
Apr 26 '07 #1
1 6020
xoinki
110 100+
hi,
I finally found the answer...

const unsigned char UNICODE_BOM[3] = {unsigned char(0xEF), unsigned char(0xBB), unsigned char(0xBF)};

int _tmain(int argc, _TCHAR* argv[])
{
FILE *fp = fopen("C:/wi32.txt", "w+");
int a = sizeof(UNICODE_BOM);
fwrite(static_cast<void *>((void *)(UNICODE_BOM)), a, 3,fp);
..........
.......
......
}
this writes the required BOM
Apr 26 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Börni | last post by:
Hi, The question might sound (and probably is;-) stupid, but why doesnt the follwing code work?? Is there something i dont see? $doc = new DOMDocument('1.0', 'iso-8859-1'); $doc->formatOutput =...
3
by: hunterb | last post by:
I have a file which has no BOM and contains mostly single byte chars. There are numerous double byte chars (Japanese) which appear throughout. I need to take the resulting Unicode and store it in a...
6
by: hpy_awad | last post by:
I am writing stings ((*cust).name),((*cust).address)to a file using fgets but rabish is being wrote to that file ? Look to my source please and help me finding the reason why this rabish is being...
8
by: Smegly | last post by:
Hi, I'm confused about a situation i have .. fprintf works in one function, but not in the other . . This is my part of my code for the two functions .. void customer(FILE *fin, FILE...
17
by: G Patel | last post by:
E. Robert Tisdale wrote: > > int main(int argc, char* argv) { > quad_t m = {0, 1, 2, 3}; > int r; > fprintf(stdout, "m = ("); > for (size_t...
4
by: baumann | last post by:
hi all, i want to use the fprintf to make log. if defined LOG_TO_FILE, it is easy to use fprintf to write the log file. if not defined LOG_TO_FILE, i want to simply write to error std...
2
by: perspolis | last post by:
Hi all I want to save my c# files with unicode encoding. I have some choices in encoding like: 1-Unicode-CodePage1200 2-Unicode(UTF8 with singnaure)-CodePage 65001 3-Unicode(UTF8 without...
1
by: xoinki | last post by:
hi all, I have some data.. and I want to save it into a file.. the data may be encoded in any format.. for simplicity let us consider, only 2 formats.. either Utf8 or latin1.. if i save latin1...
16
by: Prayag Narula | last post by:
Hi, I want to redefine fprintf for debugging purposes. That is I want that all the output that is going to the stdout should be logged in a file. I tried something like #define fprintf...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.