473,506 Members | 16,951 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

It works but I don't know why

For a while I had been needing a process to allow French-speaking
users to send text, including accented characters, to the server via
AJAX. These characters would then be left as normal accented
characters, ready to be written to a text file, or prepared for HTML
files as HTML entities.

I found a way to do it by trial and error, and it works beautifully.
Trouble is, I am writing an AJAX manual and I am supposed to guide
readers on this process - but I can't really explain why it works, as
it is not particularly intuitive. Can anybody help?

The HTML file has a meta tag in the header with the following:

content="text/html;charset=utf-8"

The Javascript sends the text after delimiting it as follows:

escape($t);

In the PHP file the following serious of functions is applied:

$t=utf8_encode($t);
$t=utf8_decode($t);
$t=stripslashes($t);

After being encoded and decoded again the accented characters come
through brilliantly. I can then either write to a text file or prepare
the text for an HTML file as follows:

$t=htmlentities($t);

The thing I do not understand is why the need encode and then decode?

I would be very grateful if somebody could throw some light on this.

Thanks for you time,

Max

May 29 '07 #1
0 1106

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

Similar topics

26
2452
by: Dan Nash | last post by:
Hi guys I have a page that is *supposed* to list the directories on the server. Here's the code... folderspec = server.MapPath("./images/") set fso =...
14
5424
by: tshad | last post by:
I posted this on the asp.net group, also. I wasn't sure whether this was an asp.net problem or a javascript problem. I have a page that was originally created from a program I found on the net...
1
1050
by: Don | last post by:
I have a user control that uses Atlas to call a web service. I drop this control on a page in the root directory and it works with no problem. I then add the control to another control, which is...
20
2842
by: Jason Dravet | last post by:
Some time ago I wrote an application that controls the projectors in our classrooms(turn on, turn off, and volume control). This application is written in VB.net 2003. It was working perfectly...
1
1445
by: Ethan Strauss | last post by:
Hi, I have a C#.net Web application which calls a web service (http://eutils.ncbi.nlm.nih.gov/entrez/eutils/soap/eutils.wsdl). It has run just fine for months. Recently I started getting...
7
6823
by: dlasusa | last post by:
Sorry if this is the wrong group...I THINK I got to the right place...(oh...and I'm a newbie programmer...so please be gentle) Anyway I have a program that works fine when I run it from within...
2
3019
by: Simon Tamman | last post by:
Just wondering if anyone knows how this component works. If you set it up in the context of an Application.Run it works on it's worker thread but it updates the progress on the UI thread. My...
7
2042
by: =?ISO-8859-1?Q?Tom=E1s_=D3_h=C9ilidhe?= | last post by:
I've purchased one already made by "Cypress Semiconductor" but it doesn't work. The VID is 04b4 and the PID is 5500. Can anyone suggest a USB to RS232 adapter that does its job perfectly 100% of...
8
6321
by: Brett | last post by:
I wrote an ASP.NET application that queries a SQL Server database (on a different box from the web server) and displays the result in a GridView. The datasource for the GridView is a SQLDataSource....
13
3705
by: Stever1975 | last post by:
I'm working on something similiar to a shopping cart item page. There is a table of items. Each item has an image, a textbox for the qty and an image for the add button. When the add image is...
0
7307
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,...
0
7370
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...
1
7021
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...
0
5614
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,...
0
4701
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...
0
3188
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...
0
3177
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1532
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 ...
1
755
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.