Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to comp.lang.java.programmer,microsoft.public.excel.programming
external usenet poster
 
Posts: 57
Default How to URL-ize a string

Hi,

Sorry for the strange crosspost - I need to solve the same problem in both
environments. I need to pass a string via GET to a script as the value of a
parameter. My string can be arbtrary and so will have spaces, ampersands,
percents, etc. So I need to replace the funny charcters with their %XX
representations. Can I find a ready routine to do this and if not, is there
a list of all substitutions that I need to make?

Thanks!

Bura


  #2   Report Post  
Posted to comp.lang.java.programmer,microsoft.public.excel.programming
external usenet poster
 
Posts: 575
Default How to URL-ize a string

Bura,

The spaces should be fine in a Get or Post statement, but you have to watch
out for ampersands and question marks, which precede each parameter
statement. The way I do this is to replace these characters with something
obscure and then Post to an asp page that replaces the obscure characters
with the originals before it does anything else.

HTH,

Robin Hammond
www.enhanceddatasystems.com

"Bura Tino" wrote in message
...
Hi,

Sorry for the strange crosspost - I need to solve the same problem in both
environments. I need to pass a string via GET to a script as the value of

a
parameter. My string can be arbtrary and so will have spaces, ampersands,
percents, etc. So I need to replace the funny charcters with their %XX
representations. Can I find a ready routine to do this and if not, is

there
a list of all substitutions that I need to make?

Thanks!

Bura




  #3   Report Post  
Posted to comp.lang.java.programmer,microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default How to URL-ize a string

"Bura Tino" wrote in message
...
Hi,

Sorry for the strange crosspost - I need to solve the same problem in both
environments. I need to pass a string via GET to a script as the value of

a
parameter. My string can be arbtrary and so will have spaces, ampersands,
percents, etc. So I need to replace the funny charcters with their %XX
representations. Can I find a ready routine to do this and if not, is

there
a list of all substitutions that I need to make?

Thanks!

Bura



java.net.URLEncoder surprisingly.

--
Tony Morris
(BInfTech, Cert 3 I.T.)
Software Engineer
(2003 VTR1000F)
Sun Certified Programmer for the Java 2 Platform (1.4)
Sun Certified Developer for the Java 2 Platform



  #4   Report Post  
Posted to comp.lang.java.programmer,microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default How to URL-ize a string

Robin Hammond scribbled the following:
Bura,


The spaces should be fine in a Get or Post statement, but you have to watch
out for ampersands and question marks, which precede each parameter
statement. The way I do this is to replace these characters with something
obscure and then Post to an asp page that replaces the obscure characters
with the originals before it does anything else.


Spaces are *not* fine in a GET or POST statement. They should be
encoded as + or %20.

--
/-- Joona Palaste ) ------------- Finland --------\
\-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
"It sure is cool having money and chicks."
- Beavis and Butt-head
  #5   Report Post  
Posted to comp.lang.java.programmer,microsoft.public.excel.programming
external usenet poster
 
Posts: 575
Default How to URL-ize a string

Thanks for the constructive comment. They work absolutely fine for me using
MSXML2.XMLHTTP40.

Robin Hammond
www.enhanceddatasystems.com

"Joona I Palaste" wrote in message
...
Robin Hammond scribbled the following:
Bura,


The spaces should be fine in a Get or Post statement, but you have to

watch
out for ampersands and question marks, which precede each parameter
statement. The way I do this is to replace these characters with

something
obscure and then Post to an asp page that replaces the obscure

characters
with the originals before it does anything else.


Spaces are *not* fine in a GET or POST statement. They should be
encoded as + or %20.

--
/-- Joona Palaste ) ------------- Finland --------\
\-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
"It sure is cool having money and chicks."
- Beavis and Butt-head





  #6   Report Post  
Posted to comp.lang.java.programmer,microsoft.public.excel.programming
external usenet poster
 
Posts: 57
Default How to URL-ize a string

"Robin Hammond" wrote in message ...
Bura,

The spaces should be fine in a Get or Post statement, but you have to watch
out for ampersands and question marks, which precede each parameter
statement. The way I do this is to replace these characters with something
obscure and then Post to an asp page that replaces the obscure characters
with the originals before it does anything else.


Thanks. But wouldn't it be better to convert them to, say, %5C and let
the server do the reverse conversions?
HTH,

Robin Hammond
www.enhanceddatasystems.com

"Bura Tino" wrote in message
...
Hi,

Sorry for the strange crosspost - I need to solve the same problem in both
environments. I need to pass a string via GET to a script as the value of

a
parameter. My string can be arbtrary and so will have spaces, ampersands,
percents, etc. So I need to replace the funny charcters with their %XX
representations. Can I find a ready routine to do this and if not, is

there
a list of all substitutions that I need to make?

Thanks!

Bura


  #7   Report Post  
Posted to comp.lang.java.programmer,microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default How to URL-ize a string

Robin Hammond wrote:

Thanks for the constructive comment. They work absolutely fine for me
using MSXML2.XMLHTTP40.


Whatever that is. They sure aren't valid HTTP; see RFC 2396, section
2.4.3. (RFC 2616, HTTP/1.1, refers to RFC 2396 for the format of a URI).

Robin Hammond
www.enhanceddatasystems.com

"Joona I Palaste" wrote in message
...
Robin Hammond scribbled the following:
Bura,


The spaces should be fine in a Get or Post statement, but you have to

watch
out for ampersands and question marks, which precede each parameter
statement. The way I do this is to replace these characters with

something
obscure and then Post to an asp page that replaces the obscure

characters
with the originals before it does anything else.


Spaces are *not* fine in a GET or POST statement. They should be
encoded as + or %20.

--
/-- Joona Palaste ) ------------- Finland
--------\ \-- http://www.helsinki.fi/~palaste ---------------------
rules! --------/ "It sure is cool having money and chicks."
- Beavis and Butt-head


--
Chris Gray
/k/ Embedded Java Solutions

  #8   Report Post  
Posted to comp.lang.java.programmer,microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default How to URL-ize a string

Robin Hammond wrote:
Thanks for the constructive comment. They work absolutely fine for me using
MSXML2.XMLHTTP40.


Perhaps that control does the encoding for you. Or perhaps you've been
lucky and only interacted with servers that are very lax in violating
that specific part of the HTTP specification. In the former case (and
if it's actually documented behavior of the control), then you're fine.
In the latter case, you should really fix this before your code starts
randomly breaking on different servers.

--
www.designacourse.com
The Easiest Way to Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
  #9   Report Post  
Posted to comp.lang.java.programmer,microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default How to URL-ize a string

I wrote:
Robin Hammond wrote:
Thanks for the constructive comment. They work absolutely fine for me using
MSXML2.XMLHTTP40.


Perhaps that control does the encoding for you. Or perhaps you've been
lucky and only interacted with servers that are very lax in violating
that specific part of the HTTP specification. In the former case (and
if it's actually documented behavior of the control), then you're fine.
In the latter case, you should really fix this before your code starts
randomly breaking on different servers.


Okay, I just checked. The documentation for the XMLHTTP control says
that the second parameter to open is a URL, and mentions nothing about
not needing to do encoding for illegal characters. So Robin, I'd
strongly suggest you fix your code.

--
www.designacourse.com
The Easiest Way to Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Change 3 letter text string to a number string Pete Excel Discussion (Misc queries) 3 December 31st 07 07:47 PM
How do I replace last numeric string from a alphanumeric string? Christy Excel Discussion (Misc queries) 3 August 11th 06 12:17 AM
Splitting a text string into string and number mcambrose Excel Discussion (Misc queries) 4 February 21st 06 03:47 PM
to search for a string and affect data if it finds the string? Shwaman Excel Worksheet Functions 1 January 11th 06 12:56 AM
Create a formula into a String then assign string to a cell Myrna Larson[_2_] Excel Programming 6 August 23rd 03 09:42 PM


All times are GMT +1. The time now is 12:55 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"