Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

session variable restore special characters visual basic

Posted on 2014-07-28
7
Medium Priority
?
384 Views
Last Modified: 2014-07-29
Hello I'm using session variables passed in a URL like this:

http://xxx.xxx.xxx.xxx/file.asp?var=básicas

Open in new window


   like you see has spanish accents now when you navigate the browser chages to this:

http://xxx.xxx.xxx.xxx/file.asp?var=b%C3%A1sicas

Open in new window


Now using in visual basic to query the string:

var = Request.QueryString("var")
Response.Write(var)

Open in new window


I have this results:

"básicas"

like you see is not "básicas"

   How can I query the string to have full "básicas" inside visual basic to put If then else conditions and more things?

   Of course we just have access real to the resulting variable session because we can't modify the source that send that links with that session variables because of that we just depend on destination visual basic query process. What code is needed to place in the visual basic script with examples?
Thank you
0
Comment
Question by:coerrace
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 58

Expert Comment

by:Gary
ID: 40225652
To be clear this encoded url parameters and nothing to do with session variables

What is your code that is decoding the url param because %C3%A1 correctly translates to á
0
 
LVL 33

Accepted Solution

by:
Big Monty earned 1000 total points
ID: 40225653
The url is being encoded, unfortunately there is no built in decode function, so you will have to use a custom function:

' URL decode to retrieve the original value

Function URLDecode(sConvert)
    Dim aSplit
    Dim sOutput
    Dim I
    If IsNull(sConvert) Then
       URLDecode = ""
       Exit Function
    End If

    ' convert all pluses to spaces
    sOutput = REPLACE(sConvert, "+", " ")

    ' next convert %hexdigits to the character
    aSplit = Split(sOutput, "%")

    If IsArray(aSplit) Then
      sOutput = aSplit(0)
      For I = 0 to UBound(aSplit) - 1
        sOutput = sOutput & _
          Chr("&H" & Left(aSplit(i + 1), 2)) &_
          Right(aSplit(i + 1), Len(aSplit(i + 1)) - 2)
      Next
    End If

    URLDecode = sOutput
End Function

Open in new window

0
 

Author Comment

by:coerrace
ID: 40225682
Thank you for answer i used your function like this:

strPath = Server.URLEncode(raceplan)
Response.write(strPath)

Open in new window



And i have like result:

"b%C3%A1sicas" without quotes

And if there are spaces fill with "+" without quotes

Not give real result how can we use that in one if then else condition? or why not give the real result.
Thank you
0
Learn how to optimize MySQL for your business need

With the increasing importance of apps & networks in both business & personal interconnections, perfor. has become one of the key metrics of successful communication. This ebook is a hands-on business-case-driven guide to understanding MySQL query parameter tuning & database perf

 
LVL 33

Expert Comment

by:Big Monty
ID: 40225690
You want to use the decode function I posted
0
 

Author Comment

by:coerrace
ID: 40225707
I'm using your function like:

strPath = URLDecode(var)

Open in new window

and the spaces are ok now but the special character like "á" (without quotes) in other words i have this result:

"básicas" without quotes

   In long names with spaces the spaces are fixed like i said you but not other characters like I mentioned. Any solution for special characters?
Thank you
0
 
LVL 53

Assisted Solution

by:Scott Fell, EE MVE
Scott Fell,  EE MVE earned 1000 total points
ID: 40225988
I wonder if you have set your code page

<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>

Open in new window

and some form of
 <meta charset="utf-8">

Open in new window


Ray's article is for the PHP topic, but relevant for ASP as well
http://www.experts-exchange.com/Programming/Languages/Scripting/PHP/A_11880-Unicode-PHP-and-Character-Collisions.html
0
 

Author Closing Comment

by:coerrace
ID: 40226889
Thank you
0

Featured Post

[Webinar] Protection from Cyberattacks

In this session, we’ll dive into the complexities of modern cyber threats and why only multi-vector protection can keep today’s businesses secure through the various stages of a cyberattack, across multiple vectors. Thursday September 14, 2017 10:00 A.M. PDT

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Does your audience prefer people in photos or no people? How can you best highlight what you’re selling? What are your competitors doing, and what can you do that is different and unique from them?  Continue reading to learn how to make your images …
Ready to get certified? Check out some courses that help you prepare for third-party exams.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).
Suggested Courses

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question