|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
How to convert character to an ASCII code |
« View previous topic :: View next topic » |
Author |
Message
|
dean |
Posted: Fri May 29, 2009 5:21 am Post subject: How to convert character to an ASCII code |
|
|
Novice
Joined: 29 May 2009 Posts: 15
|
Using ESQL, how can I convert the letters of the alphabet into their ASCII code values -- A = 65, B=66, ... Z=90.
Of course this could be done with a massive case statement...but what fun would that be. |
|
Back to top |
|
 |
zpat |
Posted: Fri May 29, 2009 5:35 am Post subject: |
|
|
 Jedi Council
Joined: 19 May 2001 Posts: 5866 Location: UK
|
Set up a 26 character long single string of the characters ABC...Z
Loop through your source string for each character (SUBSTRING) - find the position of the character in the alphabet string (using POS) and add 64.
Don't forget about lower case if appropriate and allow for characters not being found in the alphabet.
Or could just CAST each character as INTEGER and see what happens (if you are sure it is held as ASCII internally).
There could be more efficient ways, two corresponding arrays (one with letters, ones with numbers) with the most frequently occuring characters listed first would be faster to loop through.
Any number of ways to do it. |
|
Back to top |
|
 |
dean |
Posted: Fri May 29, 2009 6:53 am Post subject: |
|
|
Novice
Joined: 29 May 2009 Posts: 15
|
Thank you. The SUBSTRING solution will work just fine. |
|
Back to top |
|
 |
fjb_saper |
Posted: Fri May 29, 2009 11:10 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
dean wrote: |
Thank you. The SUBSTRING solution will work just fine. |
What about CAST AS BLOB?  _________________ MQ & Broker admin |
|
Back to top |
|
 |
|
|
 |
|
Page 1 of 1 |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|
|
|