473,804 Members | 3,220 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Where I can find a url decode algorithm

24 New Member
Hi everybody!

I have such a problem. I wrote a web portal on C++, but I found one big "-" in that script: C++ is not supporting url decoding(I mean data sent by HMTL forms).

As a developer I can solve this problem in many ways, but the easier would be, if I understand how to convert ASCII Hex (%D3 for example) to a symbol it represents.

As I guess, there must be a certain algorythm how it was encoded, and the same how it may be decoded.
As we all know there is a certain way to convert digits to binary(I mean if you have 57 for example, then:
32 16 8 4 2 1
57/32= 1 , 25/16=1, 9/8=1 , 1/4 = 0, 1/2 = 0 , 1/1 = 1, so binary is 111001.
Is there some kind of formula to convert ASCII Hex to ASCII, or easier to say how to decode URL content?
Thanks to everyone.
May 17 '07 #1
5 5495
Ganon11
3,652 Recognized Expert Specialist
If I understand it correctly, a hex number in HTML with the form %XY is a character encoded in Hexidecimal, with number value XY. To find the ASCII version, you should only have to convert to decimal. The value (in decimal) of a hex number XY is X * 16 + Y.

So, when parsing the imformation, you can look for a '%' symbol. If you find one, you have come across a hex character that needs to be decoded. Discard the '%' and retrieve the XY numbver, convert to decimal using the above formula, and then cast it to a character in order to decode.
May 17 '07 #2
wingleader
24 New Member
Pardon, I've been mistaken... It's a little bit different, first comes numder, then a char: %3A%3D%5B%5D.

each char is represented is 3 chars.

so, if i need to convert %3A to char, I need to 3x16 + A?

And the last question: how I convert decimal to char?
http://spacelogic.eu/cgi-bin/spacelogic.cgi - here is a link to script. I'm sorry it's in russian, but it works the same way.
May 17 '07 #3
Ganon11
3,652 Recognized Expert Specialist
OK, the process still holds. Remember, in hexidecimal, a letter is basically a digit. So all you have to do is get each digit individually - if a digit is a number (0-9), you can multiple normally. If it's a letter (A-F), convert it to its equivalent (A = 10, B = 11, etc), and then proceed with the multiplication.

As for the decimal number to a character, just make a char variable and initialize it to a number:

Expand|Select|Wrap|Line Numbers
  1. char myChar = 90;
May 17 '07 #4
wingleader
24 New Member
Thanks a lot! It works fine. A REALLY HUGE THANKS!!!
May 17 '07 #5
wingleader
24 New Member
By the way, do you know how russian symbols are represented in ASCII?
Somehow they all have negative values(in HEX it's %E0 and in ASCII it's -48).

PS. I found an answer. All russian symbols comes over 127 limit, and as a result, char value comes as: 127 - font_value, and here comes "-" symbol.

So huge thanks for help! I even did't hope to get answers so quickly.
May 17 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

6
14679
by: Christian | last post by:
HI, I have a function that is used to constrain a query: Select COl1, Col2 From MyTable WHERE col1 = ... AND col2 = ... And MyFunction(col1) = ... My problem is that MyFunction is executed as many times that there are
9
5972
by: Krishna Sagiraju | last post by:
Hai, I gotta decode a barcode from an image ( ppm, bmp, or jpg). I realize the first milestone would be to recognize a barcode with in the image: I took a small window (say 80X80 pixels) and if a barcode is present in this window all pixels horizontally would have the same values. Well as you can see this is not perfect. I'm right now working with PPM image. and then to decode the barcode itself (which i've no clue how to do).
0
3502
by: richasaraf | last post by:
Hello everyone, Please HELP !!!!! I'm facing problem in converting CASE statements into DECODE. As i have PL/SQL 8i, so it does not handle CASE statements. Please send me the solutions . Then basic problem is the CASE has NOT condition i.e. <> ...... and this particularly i'm not able to convert in DECODE. Please send me the solution as early as possible.. I'm stuck up !!! I'm giving below the CASE statements and the DECODE...
5
2580
by: Draw | last post by:
Hi All, Just a thought, about the find() algorithm in the C++ STL. I read that the find algorithm can take a range of iterators. If it does not find the element it is looking for in that range it returns the iterator to the last element in the range, not to the last element in the container, to the last element in the range. That being said, how can we tell if find() has been successful in finding the element we need? Its easy when we...
2
3428
by: rsd | last post by:
Hi, I'm trying get Samsung YH-920 mp3 player to work with Debian GNU/Linux. To do that I need to run http://www.paul.sladen.org/toys/samsung-yh-925/yh-925-db-0.1.py script, the idea behind the script is described at http://www.paul.sladen.org/toys/samsung-yh-925/ I'm getting errors and hoping someone could give me some hints, for I have no python background.
10
7535
by: Christian Chrismann | last post by:
Hi, I've a question on the STL find algorithm: My code: int main( void ) { vector< ClassA* myVector; ClassA *ptrElement1 = ...;
2
2728
by: hojjatnikan | last post by:
please help me this code 62EH&5gx0wiqoQFw is this name ( Belux) but i dont know how convert it i dont know the algorithm of this code plead help me
7
9756
by: php.developer2007 | last post by:
I want to know to decode sha1 encoded url into normal url. Example www.example.com/<sha1 code>/index1.htm I want this to www.example.com/index1.htm
1
5782
by: anonymous | last post by:
1 Objective to write little programs to help me learn German. See code after numbered comments. //Thanks in advance for any direction or suggestions. tk 2 Want keyboard answer input, for example: answer_str = raw_input(' Enter answer ') Herr Üü
0
9707
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10586
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10323
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10082
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9161
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7622
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6856
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4301
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2997
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.