473,779 Members | 2,064 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to encode/decode a HTML using C++??

Hi,

Is there a way to encode/decode HTML using C++??

Thanks,
Sarada.

Feb 16 '06 #1
7 16606
Be more specific.

In several application development softwares there are readymade
components which can interpret HTML.

Feb 16 '06 #2
sa*****@gmail.c om wrote:
Hi,

Is there a way to encode/decode HTML using C++??


Encode and decode into what? Where is the html/source coming from?
Where should it go to?

Take a look at:

std::string;

Ben Pope
--
I'm not just a number. To many, I'm known as a string...
Feb 16 '06 #3
* sa*****@gmail.c om:

Is there a way to encode/decode HTML using C++??


No way. Those web-browser said to implemented in C or C++? Well, it's
just a sham, they're all implemented in JavaScript.

Hth.,

- Alf
PS: HTML is just plain text, so what is the problem?

--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Feb 16 '06 #4
I have a C++ function which returns a string and later this string is
used by ASP for display. If I use HTMLEncode in ASP this solves my
problem. But there are some cases where the string output is an image
tag and I don't want HTMLEncode to show the tag as it is. I am trying
to remove the HTMLEncode in ASP and try to encode the string in C++
before sending it to ASP. Please let me know if this is clear or any
thoughts are welcome.
Thanks

Feb 16 '06 #5
Encoding it is simple. Decoding takes a slightly longer function, doing
the same thing in reverse. Note that this won't work on EBCDIC based
machines (silly IBM).

To selectively encode different tags, parse the input string and output
the code depending on what you want.

Assuming you don't have an operating system or library function to do
the work for you, it is:

string EncodeHtml(cons t wstring& html)
{
ostringstream result;
wstring::const_ iterator i;
for (i = html.begin(); i != html.end(); ++i)
{
if (*i >= 128)
result << "&#" << static_cast<int >(*i) << ";";
else if (*i == '<')
result << "&lt;";
else if (*i == '>')
result << "&gt;";
else if (*i == '&')
result << "&amp;";
else if (*i == '"')
result << "&quot;";
else
result << static_cast<cha r>(*i); // Copy untranslated
}
return result.str();
}

Feb 16 '06 #6
Thanks for your help!

Feb 16 '06 #7
Hmm, I don't know about your newsreader, but my posted code is showing
up wrong on google groups, despite "Preview" working.
i.e. "ampersand L T semicolon" ("&lt;") is showing up as "<" which
defeats the point really. The appropriate strings (using string literal
concatenation) are:
"&" "lt;"
"&" "gt;"
"&" "amp;"
"&" "quot;"
I hope the mangling was just at the client end, but still it could be
annoying if you are viewing newsgroups using a web browser. Oh well.

Feb 17 '06 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
2313
by: fowlertrainer | last post by:
Hi ! I'm hungarian, we use special characters like: á - a' õ -o" etc. I want to encode this characters to in config file I see these characters as \nnn format.
3
2569
by: Ricky | last post by:
Is there any way to detect if a field has been encoded before I decode a field.
4
4925
by: Newbie | last post by:
How would I modify this form to encode *all* the characters in the 'source' textarea to the '%xx' format & place result code into the 'output' textarea? (cross browser compatable) Any help is appreciated. Regards.
1
21567
by: AR | last post by:
I would like to know more about the Encode/Decode feature available within MS Access. This is what I have read from Microsoft Office OnLine: "The simplest method of protection is to encode the database. Encoding a database compacts the database file and helps protect it from being read by a word processor." Is this recommended as a best practice? What is the impact on
4
7579
by: Darrel | last post by:
How does HTML.encode work? I'm trying to save text in a hidden form field into a SQL DB. The tedt is HTML (from a WYSIWYG editor...X-standard). One problem I have is that stray apostrophe's in the HTML text are throwing a SQL error. Html.encode doesn't seem to do anything with these, eh? Secondly, does HTMLencode also encode already encoded items?
7
9011
by: jtfaulk | last post by:
I need to encode some information on the server side using ASP.NET with C#; sending via HTTP to a client side application, that needs to be decoded in an MFC C++ application. I'm not sure if I can encode something using: C#: System.Security.Cryptography (to encode) and
6
2336
by: 7stud | last post by:
s1 = "hello" s2 = s1.encode("utf-8") s1 = "an accented 'e': \xc3\xa9" s2 = s1.encode("utf-8") The last line produces the error: --- Traceback (most recent call last):
4
8253
by: J Peyret | last post by:
Well, as usual I am confused by unicode encoding errors. I have a string with problematic characters in it which I'd like to put into a postgresql table. That results in a postgresql error so I am trying to fix things with <string>.encode he Company�s ticker Trying for an encode:
1
5778
by: anonymous | last post by:
1 Objective to write little programs to help me learn German. See code after numbered comments. //Thanks in advance for any direction or suggestions. tk 2 Want keyboard answer input, for example: answer_str = raw_input(' Enter answer ') Herr Üü
0
9636
marktang
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...
0
10306
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10139
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10075
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8961
agi2029
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...
1
7485
isladogs
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...
1
4037
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
2
3632
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2869
bsmnconsultancy
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...

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.