Solved

Convert ascii values to character within string

Posted on 2006-07-20
6
227 Views
Last Modified: 2010-04-30
Experts, I need help searching through a string and converting ascii hex values to characters. Below is the string i need to parse. The ascii hex values are preceeded by % and I need to replace this with the character value. For example in the &email tag I need to replace %40 with @.


string contents:
dim str as string
-----------------------------------------------------
str = customer_id=255349&authorized=no&first_name=test&last_name=order&phone=5618662933&email=test%40test.com&product=50&username=&password=&shipping_address=1124+apollo+rd&shipping_unit=1124+apollo+rd&shipping_city=Melbourne&shipping_state=FL&shipping_zip=32935&shipping_country=US&billing_address=1124+apollo+rd&billing_unit=1124+apollo+rd&billing_city=Melbourne&billing_state=FL&billing_zip=32935&billing_country=US&cc_number=5454545454545454&cc_expires=2011-05-30+23%3A59%3A59&cc_name_on_account=test+order&cc_ccid=123
0
Comment
Question by:Dalexan
[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
  • 3
  • 3
6 Comments
 
LVL 76

Accepted Solution

by:
GrahamSkan earned 125 total points
ID: 17147740
Not efficient, but it works:

For i = 0 To 255
    str = Replace(str, "%" & Right$("0" & Hex$(i), 2), Chr$(i))
Next i
0
 

Author Comment

by:Dalexan
ID: 17148041
This is cutting off the end of the string at position 425? It is changing what it leaves to the character code.
0
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 17148660
Do you still have a truncating problem. I can't reproduce it myself?
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:Dalexan
ID: 17148685
Rather than breakdown the whole string im going to try parsing the tags which should work. You might be able to answer my other question though

http://www.experts-exchange.com/Programming/Programming_Languages/Visual_Basic/Q_21926303.html
0
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 17149438
Thanks. I have seen it and contributed. It looks like the gang has arrived.
0
 

Author Comment

by:Dalexan
ID: 17149463
I will be awarding points shortly
0

Featured Post

[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
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…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses
Course of the Month5 days, 7 hours left to enroll

627 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