473,657 Members | 2,499 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=ut f-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 1115

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

Similar topics

26
2469
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 = CreateObject("Scripting.FileSystemObject") set fold = fso.GetFolder(folderspec) for each subfolder in fold.subFolders Response.Write(subfolder.name & "<br>")
14
5453
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 that works well as an html page. It brings up a modal popup window that I have been trying to work out for days now and this was the closest I have been able to come. I added a little asp.net code and an asp.net button and cannot get it to
1
1060
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 on another page and it will not work. It does not seem to know what the webService is. My web service is in the same project and the ascx control and is named meterCommunication.asmx in a folder called webService. The control is a button...
20
2866
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 until XP SP2 was installed on the PCs. Now when the power on or power off button is pressed the following message is displayed: An unhandled exception has occurred in your application. If you click Continue, the application will ignore this...
1
1448
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 "System.Net.WebException: The underlying connection was closed" errors. I started the application up in debugging mode and it ran fine. After fiddling with things for awhile I now find that it works while I am running in debug mode, but does not when I am...
7
6829
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 VS2005 (no errors and does exactly what it should) BUT if I build it and then try to run the .exe on the same computer it fails with: "Unhandled exception...."
2
3027
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 question is, how does it know which thread to use? I used Reflector to track down the fact that it gets the delegates to call via base.Events which derives from Component but how does it know what to put into base.Events? I'm very happy the...
7
2060
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 the time under Microsoft Windows, i.e. it trully behaves exactly just like any other serial port?
8
6327
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. Just to get it to work, I hard-coded the username and password of a SQL Server account in the connectionstring in web.config. Once I confirmed that this worked on the web server, I wanted to remove the hard-coded password from web.config, so I...
13
3723
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 clicked it adds the item to the cart array and sums it if the item already exists in the cart. This code works perfectly fine in Internet explorer and firefox, heck I even tested it in chrome and it works. So everything works fine in all browsers...
0
8397
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
8310
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,...
0
8827
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
8732
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
8503
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
8605
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7333
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...
0
5632
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();...
0
4158
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 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.