When I read an HTML file starting with
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8">
and then I write it into another file, say OUTPUT.txt, I get an
inverted question mark, "¿",
at the beginning of the OUTPUT.txt file. Why is that?
Thanks!
mary
PS. I use:
string line;
while (getline(in,lin e)) {
out.write(line. c_str(),line.si ze());
out.put('\n');
} 5 6354
Seems odd. Maybe, just maybe there is an empty or blank line at the
beginning of your source file? In that case during the first iteration
of the while loop line would be empty. Now, it *should* be ok to call
write with a char count of 0 and have it do nothing... But maybe there
is a problem with your stream code? Try adding a simple test:
while (getline(in,lin e)) {
if( ! line.empty() )
{
out.write(line. c_str(),line.si ze());
out.put('\n');
}
}
Phil,
Here is the code. It still does it with any file starting with
anything!
Thanks!
Mary
@@@@@@@@@@@@@@@ @@@@@@@@
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
string line;
int main()
{
ifstream in("INPUT.txt", ios::in);
if (!in) {
cout << "Cannot Open the INPUT file.\n";
return 1;
}
ofstream out("OUTPUT.txt ",ios::out) ;
if (!out) {
cout << "Cannot Open the OUTPUT file.\n";
in.close();
return 1;
}
while (getline(in,lin e)) {
if( ! line.empty() ) {
out.write(line. c_str(),line.si ze());
out.put('\n');
}
}
in.close();
out.close();
return 0;
}
@@@@@@@@@@@@@@@ @@@@@@@@@
On Sun, 13 Mar 2005 21:26:05 -0700, Phil Staite <ph**@nospam.co m>
wrote: Seems odd. Maybe, just maybe there is an empty or blank line at the beginning of your source file? In that case during the first iteration of the while loop line would be empty. Now, it *should* be ok to call write with a char count of 0 and have it do nothing... But maybe there is a problem with your stream code? Try adding a simple test:
while (getline(in,lin e)) { if( ! line.empty() ) { out.write(line. c_str(),line.si ze()); out.put('\n'); } }
mary wrote: When I read an HTML file starting with
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8">
and then I write it into another file, say OUTPUT.txt, I get an inverted question mark, "¿", at the beginning of the OUTPUT.txt file. Why is that?
Are you saving the file with Notepad.exe?
That program prefixes files that it perceives as Unicode (even UTF-8) with a
Byte Order Mark. If you use an editor to open your file in hex (or "binary")
mode, you might see the BOM, FEFF or FFEF, at the beginning.
Your output system does not interpret the codes as UTF-8, so it probably
uses ISO Latin-1. That has no glyph for FF or EF, so you get a "missing
glyph" symbol as ¿.
This could all be wrong, but the details are off-topic, so nobody is allowed
to contradict me.
--
Phlip http://industrialxp.org/community/bi...UserInterfaces
mary wrote: out.write(line. c_str(),line.si ze()); out.put('\n');
I don't see anything wrong with your code, but the above lines could be
simplified to:
out << line << '\n';
On Mon, 14 Mar 2005 06:16:12 GMT, Phlip wrote: mary wrote:
When I read an HTML file starting with
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8">
and then I write it into another file, say OUTPUT.txt, I get an inverted question mark, "¿", at the beginning of the OUTPUT.txt file. Why is that?
Are you saving the file with Notepad.exe?
That program prefixes files that it perceives as Unicode (even UTF-8) with a Byte Order Mark. If you use an editor to open your file in hex (or "binary") mode, you might see the BOM, FEFF or FFEF, at the beginning.
Your output system does not interpret the codes as UTF-8, so it probably uses ISO Latin-1. That has no glyph for FF or EF, so you get a "missing glyph" symbol as ¿.
This could all be wrong, but the details are off-topic, so nobody is allowed to contradict me.
Well, your reasoning is correct, but not your facts. A Unicode file may
start with FEFF or FFFE (not FFEF) to indicate endianness. A UTF-8 file,
however, starts with EFBBBF if it has a BOM mark at all. But, no doubt, the
BOM mark is what the OP is seeing.
--
Sven Axelsson, Sweden This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Kiki Novak |
last post by:
Hi,
I'm an Austrian writer living in Montpezat (South France), and I'm currently
busy converting some of my writings from LaTeX to HTML to publish them on
the Internet.
The novel I'm working on has two different first-person narrators, formally
distinguished by the use of italics. One of them (Violetta) only appears in
italics, the other one (Victor) in normal fonts. This is a formal help for
the reader to distinguish the two...
|
by: rorley |
last post by:
I'm new to Python and I'm struggling. I have a text file (*.txt) with
a couple thousand entries, each on their own line (similar to a phone
book). How do I make a script to create something like an inverted
dictionary that will allow me to call "robert" and create a new text
file of all of the lines that contain "robert"?
Thanks so much.
|
by: Logan |
last post by:
I am drawing the current cursor on a zoomed in view of the desktop which
seems to be work for all of the cursor types, except that the IBeam is
always being drawn inverted (white) even when it should be drawn black.
My Code:
public struct POINT
{
public Int32 x;
public Int32 y;
|
by: Mark Hobley |
last post by:
I have some information that states that the if conditional can be be inverted
from the traditional syntax
if (EXPRESSION) BLOCK
to an alternative syntax:
if BLOCK (EXPRESSION);
I have a simple line of code:
|
by: vd12005 |
last post by:
Hello,
While playing to write an inverted index (see:
http://en.wikipedia.org/wiki/Inverted_index), i run out of memory with
a classic dict, (i have thousand of documents and millions of terms,
stemming or other filtering are not considered, i wanted to understand
how to handle GB of text first). I found ZODB and try to use it a bit,
but i think i must be misunderstanding how to use it even after reading...
| |
by: weird0 |
last post by:
I have to create a string that contains inverted commas inside it.
How can i do that in c#?
As follows:-
"AT+CMGF=1"
string temp=""AT+CMGF=1""; // not valid
|
by: Geosondaman |
last post by:
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv)
{
int i=0, j;
while (++i<10) {
j=9;
while (++j<=i) {
printf("*");
|
by: Shashank tiwari |
last post by:
Hi
I am trying Putting single inverted comma before a digit in Excel and a single inverted comma after the number and a comma to follow. Eg. '234567',
Can anybody tell us how to do it for 7000 records
Thanks
|
by: vbiswsu |
last post by:
Hi ,
I am facing a strange problem.I am supporting a application which is in VB and database is Oracle 9i.Now the problem is one of the production user(Say USER 1) is getting an inverted question mark instead of apostrophe in one text box(it is retreving varchar information from database) but the another user (SAY USER 2)is not facing the same issue. I had checked both the machines and only difference i got is one of them have SP3(USER 1) and...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |