|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
  |
|
hex to char in Java (changed code from earlier ESQL) |
View previous topic :: View next topic |
Author |
Message
|
namartakumari |
Posted: Sun Mar 15, 2015 5:32 am Post subject: hex to char in Java (changed code from earlier ESQL) |
|
|
Newbie
Joined: 15 Mar 2015 Posts: 2
|
Hi,
In esql i have used below code ..
SET a= 'F03A04C188E58000' ;
SET Root.ISO.aBit = CAST(a AS CHARACTER CCSID 923 ENCODING 273) ;
now we need to convert the above code to java.
a field is ISO8583 format values. based on those values i need to decode the whole message of ISO8583 format.
while decoding using the code shown below.
DECLARE CharaBit BLOB CAST(a) AS BLOB CCSID 923 ENCODING 273);
DECLARE CharaBlob BLOB CAST(CharaBit AS BLOB);
In java i have passed the value to variable 'primary'
String primary ="ð:Á?å?"; -- char value of value F03A04C188E58000.
but whlie passing the above 'primary' variable from java to esql, it is coming as
CharPrimaryBit = f03a04c13fe53f31
but what I am expecting is : f03a04c188e58000
please help me to sort it out.
hoping for some solution soon.
Thanks.
Last edited by namartakumari on Mon Mar 16, 2015 12:26 am; edited 2 times in total |
|
Back to top |
|
 |
fjb_saper |
Posted: Sun Mar 15, 2015 9:06 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
What you are looking for is a bit wise operation to mark some fields as being set or not. You should in no way be using a string for that.
Use an integer or a long and in your case as the parse won't work (neg value), use BigInteger!!.
remember decode will only go to the max positive value (signed).
So if your hex value is greater than 7F something... you could go for the complement (XOR) and subtract 1 or use BigInteger!!!
Least known but easiest to use in your case... Use BigInteger... all the bit wise operations are good. And no exception with
new BigInteger("f03a04c188e58000",16);
Have fun  _________________ MQ & Broker admin |
|
Back to top |
|
 |
namartakumari |
Posted: Sun Mar 15, 2015 9:48 pm Post subject: |
|
|
Newbie
Joined: 15 Mar 2015 Posts: 2
|
Hi,
I just want to store the char value of given hex (f03a04c188e58000) . i have tried converting the hex value to char . it is coming as ð:Á?å? ..which is the value of f03a04c188e580. 00 is null in char. how to store that extra 2 zeros also in char value.
Thanks..
Looking for sloution soon... |
|
Back to top |
|
 |
fjb_saper |
Posted: Sun Mar 15, 2015 10:32 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
Already told you that you're not dealing with a char[]. You are dealing with something that does not fit the range of admissible values for a char...
At best you can get a String representation of the hex values of the byte[] involved (long or BigInteger...).
Use a BigInteger for parsing or serializing the underlying storage.
check out
Code: |
BigInteger bi = new BigInteger("f03a04c188e58000", 16);
System.out.println(bi.toString(16)); |
Have fun  _________________ 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
|
|
|
|