Author |
Message
|
christopher j |
Posted: Tue Jul 06, 2010 10:20 am Post subject: how to convert string to ASCII by using ccsid or encoding |
|
|
Novice
Joined: 01 Jan 2010 Posts: 20
|
hi
could you please help me to convert string(contains numbers ad alphabets) to ASCII by using ccsid or encoding |
|
Back to top |
|
 |
kimbert |
Posted: Tue Jul 06, 2010 10:30 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
We will - but only if you tell us where you have looked for the answer, and what you have tried. We only give out free help to people who have made an effort to find the answer for themselves. |
|
Back to top |
|
 |
Vitor |
Posted: Tue Jul 06, 2010 11:44 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
kimbert wrote: |
We will - but only if you tell us where you have looked for the answer, and what you have tried. We only give out free help to people who have made an effort to find the answer for themselves. |
You might also want to give us a clue about what this string is being converted from. Also the platforms involves, versions of WMQ in use and if this is an unloaded COBOL copybook moving from z/OS.  _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
fjb_saper |
Posted: Tue Jul 06, 2010 12:10 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
Vitor,
Think of string as a loose companion in .NET to java.lang.String... with string being a in a Unicode representation...
Now Christopher could also be talking about C/C++?...  _________________ MQ & Broker admin |
|
Back to top |
|
 |
Vitor |
Posted: Tue Jul 06, 2010 12:19 pm Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
fjb_saper wrote: |
Think of string as a loose companion in .NET to java.lang.String... with string being a in a Unicode representation...
|
Oh Lord - Java!
Run away, run away.....  _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
mqjeff |
Posted: Tue Jul 06, 2010 12:24 pm Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
fjb_saper wrote: |
Vitor,
Think of string as a loose companion in .NET to java.lang.String... with string being a in a Unicode representation...
Now Christopher could also be talking about C/C++?...  |
But given that we're in The Broker forum, it's likely an ESQL CHARACTER variable. |
|
Back to top |
|
 |
christopher j |
Posted: Wed Jul 07, 2010 11:46 am Post subject: |
|
|
Novice
Joined: 01 Jan 2010 Posts: 20
|
I am trying in a below way to convert CHARACTER into ASCII
DECLARE rec CHARACTER;
SET rec='1811 ';
SET Environment.Variables.blobREC=CAST(rec as BLOB CCSID 819)
But i am not sure whether this conversion is correct. |
|
Back to top |
|
 |
fjb_saper |
Posted: Wed Jul 07, 2010 1:05 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
christopher j wrote: |
I am trying in a below way to convert CHARACTER into ASCII
DECLARE rec CHARACTER;
SET rec='1811 ';
SET Environment.Variables.blobREC=CAST(rec as BLOB CCSID 819)
But i am not sure whether this conversion is correct. |
Looks correct to me.  _________________ MQ & Broker admin |
|
Back to top |
|
 |
smdavies99 |
Posted: Wed Jul 07, 2010 9:23 pm Post subject: |
|
|
 Jedi Council
Joined: 10 Feb 2003 Posts: 6076 Location: Somewhere over the Rainbow this side of Never-never land.
|
So, you are using 8859-1 as your character set.
What happens when you want to encode (and later decode properly) a character that is not in 8859-1 like say a Euro Symbol?
Then you will need 8859-15 (aka 923)
Unless you understand totally the limitations of casting to a non UTF character set please don't hard code the CCSID. _________________ WMQ User since 1999
MQSI/WBI/WMB/'Thingy' User since 2002
Linux user since 1995
Every time you reinvent the wheel the more square it gets (anon). If in doubt think and investigate before you ask silly questions. |
|
Back to top |
|
 |
kimbert |
Posted: Thu Jul 08, 2010 1:51 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
Quote: |
But i am not sure whether this conversion is correct. |
Two questions:
- What, specifically, are you 'not sure' about? Are you asking us to confirm that your CAST statement looks OK ( it does to me )?
- What's special about CCSID 819? Why not use a Unicode code page, which will always be safe? |
|
Back to top |
|
 |
christopher j |
Posted: Thu Jul 08, 2010 9:51 am Post subject: |
|
|
Novice
Joined: 01 Jan 2010 Posts: 20
|
When i am casting ' ' (space) to an ascii value, ccsid-819 converts it into 20.But the actual ascii value for ' ' is 32.How to achieve that? |
|
Back to top |
|
 |
smdavies99 |
Posted: Thu Jul 08, 2010 10:15 am Post subject: |
|
|
 Jedi Council
Joined: 10 Feb 2003 Posts: 6076 Location: Somewhere over the Rainbow this side of Never-never land.
|
Ask yourself what the HEX representation of 32 is _________________ WMQ User since 1999
MQSI/WBI/WMB/'Thingy' User since 2002
Linux user since 1995
Every time you reinvent the wheel the more square it gets (anon). If in doubt think and investigate before you ask silly questions. |
|
Back to top |
|
 |
kimbert |
Posted: Thu Jul 08, 2010 11:22 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
Can I just ask an important question? Why do you want to convert this string to ASCII? What is your message flow trying to do, that requires this? |
|
Back to top |
|
 |
|