ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » General IBM MQ Support » How to convert character to an ASCII code

Post new topic  Reply to topic
 How to convert character to an ASCII code « View previous topic :: View next topic » 
Author Message
dean
PostPosted: Fri May 29, 2009 5:21 am    Post subject: How to convert character to an ASCII code Reply with quote

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
View user's profile Send private message
zpat
PostPosted: Fri May 29, 2009 5:35 am    Post subject: Reply with quote

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
View user's profile Send private message
dean
PostPosted: Fri May 29, 2009 6:53 am    Post subject: Reply with quote

Novice

Joined: 29 May 2009
Posts: 15

Thank you. The SUBSTRING solution will work just fine.
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Fri May 29, 2009 11:10 am    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » General IBM MQ Support » How to convert character to an ASCII code
Jump to:  



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
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.