NetTalk Central

Author Topic: HOW TO: unescape a URL part?  (Read 2436 times)

patrick de laet

  • Newbie
  • *
  • Posts: 35
    • View Profile
    • ShopPlus
    • Email
HOW TO: unescape a URL part?
« on: December 07, 2011, 11:05:43 AM »
My URL contains my product categoriees in some part of the URL.
eg: http://81.83.9.39:88/nl/produkten/luchtwegen/a%C3%ABrosol/1 is in the URL but my productcategory is 'äerosol'.
In my webserver, I'll extract the productcategories from the URL in order to do a SQL SELECT * WHERE PRODUCTCATEGORIES = 'äerosol'
But this never returns any rows because my productcategory is encoded in the URL ('a%C3%ABrosol')
How do I decode 'a%C3%ABrosol' to 'äerosol'?

PS: I also have StringTheory - maybe there is a method to do it?

regards

Patrick De Laet


Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11244
    • View Profile
Re: HOW TO: unescape a URL part?
« Reply #1 on: December 07, 2011, 10:12:39 PM »
Hi Patrick,

the answer is simple, but also complex.
so yes, there is a method you can use, p_web._Unescape(string,[flags])
as in

prodcat = p_web._unescape(prodcat)

that's the simple part. The more complex part is that the "kind of encoding" does matter.
In this case it looks to me like the incoming string is utf-8 encoded. Now you _may_ be able to pass this directly
to SQL - I guess that depends on whether SQL is expecting utf-8 encoding or not.

If not, you need to convert that to ANSI. There is a StringTheory method to do this, or you can use the
p_web.UtfToAscii method.

prodcat = p_web.UtfToAscii(p_web._unescape(prodcat))

Cheers
Bruce