473,387 Members | 1,624 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,387 software developers and data experts.

php rawurldecode from javascripts' escape()

Hi,

I'm sending some vars to php from javascript. These vars contain
special chars (like "&" ,",")and also turkish characters. Therefore
I'm using javascripts escape() function to be able to send them
properly. My problem is on the php side. I am using rawurldecode to
convert them back. However, Turkish characters like "I" (capital "I"
with a dot on top) for example still stay encoded as "%u0130".

My page is setup to handle turkish chars and if sent from a database,
display properly. I've googled for an answer and cant find anything.

I've also tried looking at base64 encoding from javascripts' end, to
again decode using base64Decode from php, but nothing seems to work
right.

Does anyone have any sugestions?

Thanks in advance,

Swayze

Oct 28 '05 #1
4 4049
swayze wrote:
I'm sending some vars to php from javascript. These vars contain
special chars (like "&" ,",")and also turkish characters. Therefore
I'm using javascripts escape() function to be able to send them
properly. My problem is on the php side. I am using rawurldecode to
convert them back. However, Turkish characters like "I" (capital "I"
with a dot on top) for example still stay encoded as "%u0130".


the doc for rawurldecode() says it decodes percent-encodings, but since
'%u0130' isn't a percent-encoding rawurldecode() doesn't decode it. to my
knowledge there isn't a (PHP) function which decodes your encodings.

encoded as UTF-8 and percent-encoded, as RFC3986 prescribes, 'Ä°' (U+0130)
is represented in URIs as <%C4%B0>. rawurldecode('%C4%B0') here gives me
the letter 'Ä°'.

--
Jock
Oct 29 '05 #2

swayze wrote:
Hi,

I'm sending some vars to php from javascript. These vars contain
special chars (like "&" ,",")and also turkish characters. Therefore
I'm using javascripts escape() function to be able to send them
properly. My problem is on the php side. I am using rawurldecode to
convert them back. However, Turkish characters like "I" (capital "I"
with a dot on top) for example still stay encoded as "%u0130".


Try using encodeURIComponent() instead of escape(). The function won't
help you though if you're not using UTF-8.

Instead of dealing with encoding issues manually, I would just create a
hidden form on the fly, fill it in, and submit it.

Oct 29 '05 #3
thanks for the replies. I'll try using encodeURIComponent() and hope
for the best. However, if this does not solve my problem, this form on
the fly, what did you have in mind? (Please bear with me. I'm originaly
a .net programmer :-S )

Let me explain my situation:

Right now I'm using iframes. a left and a right frame.
The left frame accesses the db, uses a web service, displays some
stuff, user interacts with the stuff, reaccesses db, web service ect...
at the end I'm changing, with javascript, the location of the right
frame with something like "parent.RIGHT.location =
'right.php?somevar='+might_have_turk_chars" in order to refresh the
contents. I could just send the right frame some numbers, but the with
all the intensive (and also redundant because the left frame has
already done all of it) webservice and db accesses, the delay can be
rather long. I'm just want to send the data to the right frame to be
appended to the existing data. I've considered updating the right frame
only using javascript, but found that building complex table structures
only using javascript and DOM with tds able to respond to javascript
events a little too challenging.

thaks again,

Swayze

Oct 30 '05 #4
swayze wrote:
thanks for the replies. I'll try using encodeURIComponent() and hope
for the best. However, if this does not solve my problem, this form on
the fly, what did you have in mind? (Please bear with me. I'm originaly
a .net programmer :-S )
Well, you would have a form with a hidden fields. Set the target of the
form to the frame you want, set the fields to the correct values, then
call submit() to send it. If the method is GET, then it's equivalent to
doing a location = <url>.
I've considered updating the right frame
only using javascript, but found that building complex table structures
only using javascript and DOM with tds able to respond to javascript
events a little too challenging.


It's not that hard really. The trick is to not try to construct the
page programmatically. Instead, build the HTML of the page as through
you'd on the server side, then do document.open(),
document.write(html), and document.close().

Oct 30 '05 #5

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

Similar topics

1
by: Elf M. Sternberg | last post by:
It's all Netscape's fault. RFC 2396 (URI Specifications) specifies that a space shall be encoded using %20 and the plus symbol is always safe. Netscape (and possibly even earlier browsers like...
3
by: Kerberos | last post by:
When I deliver a page as text/html, the javascripts work, but if delivered as application/xhtml+xml, the javascripts don't work: function OpenBrWindow(theURL,winName,features, myWidth, myHeight,...
2
by: sdvoranchik | last post by:
We have an application that contains links that run javascripts to create pages in a separate frame. When these links open an external site, it causes the javascripts to no longer function. When...
2
by: LC's No-Spam Newsreading account | last post by:
I asked a couple of days ago about the following arrangement (simplified). I made some progress using netscape.security.PrivilegeManager.enablePrivilege but still have to ask some further help. ...
4
by: David Virgil Hobbs | last post by:
My web host inserts banner ads into my html pages. The javascript in these banner ads interferes with the onload triggered javascript functions in my pages. Whether I trigger my javascript...
6
by: daniel kaplan | last post by:
hi all, very new to this (javascript and the likes) so this might range in the dumb cataegory. when i am saving my external javascripts on the same server as all my HTML and Perl, etc scripts,...
2
by: and | last post by:
Hi I have been validating all day most things are cool but I cant get by this problem. One I have listed the script (JAVASCRIPT ) in all the right placesnot a prob but the validator insists...
2
by: Pavils Jurjans | last post by:
Hello, I am looking fow C# equivalent of JavaScripts escape() and unescape() functions. I need to use C# function at the server side and then be able to use the opposite at the client side. ...
4
by: januarynow | last post by:
Generally, my site contains javascripts (a couple of freebie counters plus some CPM (pay-per-impression) and CPC (pay-per-click) ads), from four different firms, but they are all suffering from the...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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...
0
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,...
0
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...
0
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
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...

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.