[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [ajug-members]: Java/Flash URL Encoding



I'm not so sure changing encodings with URLEncoder will help render the 
space as anything but a plus.  Perhaps the best route right be to define 
your own encoder that extends java.net.URLEncoder - first calling 
super.encode(), then use something like commons StringUtils 
(http://jakarta.apache.org/commons/lang/api/org/apache/commons/lang/StringUtils.html)  
to replace any occurences of + with %20.  The only real problem depends 
on how/if URLEncoder encodes a plus sign - don't want to undo that.  I 
know it's not the pre-written solution you'd prefer, but the workaround 
isn't too cumbersome.

-Rob

Dan Glauser wrote:

>Hello All,
>
>As a temporary solution I'm encoding an xml string and placing it in a
>JSP page that has a Flash component.  The problem is the encoding is
>different, Flash's encoding expect a space to be represented as:
>
>%20
>
>Whereas java.net.URLEncoder.encode(String, "UTF-8") represents a space
>as:
>
>+
>
>This isn't the only difference but just one example.  Does anyone have
>any experience getting these two encoders to place nicely together?  I'm
>not locked into UTF-8 on the Java side, I don't care what it is.  I'm
>just trying to match it up to the Flash encoder.  Unfortunately the
>documentation on the Flash side is rather sparse.
>
>Any ideas are appreciated.
>
>Thanks!
>
>  
>