Solved

Convert ascii values to character within string

Posted on 2006-07-20
6
223 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
  • 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
add text to end of existing text in file 16 69
String manipulation in Visual Basic 7 60
Sending a email via excel using vba 6 72
VB6 - Convert HH:MM into Decimal 8 53
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

862 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

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now