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 » WebSphere Message Broker (ACE) Support » CCSID for Trademark

Post new topic  Reply to topic
 CCSID for Trademark « View previous topic :: View next topic » 
Author Message
RB
PostPosted: Fri Dec 07, 2007 2:47 pm    Post subject: CCSID for Trademark Reply with quote

Acolyte

Joined: 23 May 2006
Posts: 56

All,

I have a java program reading a file and writing it to the queue. The program is creating issues whenever the input message has special characters like trademark symbol.

I tried couple of options, but nothing seems to work. I am not sure whether it is the reading file part or the writing to the queue part affecting the byte stream. It looks like the output is always defaulted to UTF-8.

The sample code is as given below.

Code:


reading section-
-----------------
FileInputStream instr = new FileInputStream(files[i]);
            InputStreamReader instrR = new InputStreamReader(instr,"ISO-8859-1");

if (filelength > 0) {
                  StringBuffer sb = new StringBuffer();
                  char[] b = new char[BLOCK_SIZE];
                  int n;

                  // read a block, if it gets any chars, append them.
                  while ((n = instrR.read()) > 0) {
                     //sb.append(b, 0, n);
                     sb.append((char)n);
                  }

instrR.close();
writing section
----------------

Hashtable env = new Hashtable();
         env.put(Context.INITIAL_CONTEXT_FACTORY, initialContextFactory);
         env.put(Context.PROVIDER_URL, providerUrl);

         env.put("CCSID", new Integer(1208));

jndiContext = new InitialDirContext(env);
         // Get a QueueConnectionFactory.
         queueConnectionFactory = (QueueConnectionFactory) jndiContext.lookup(qcfName);
         // The Queue object from the JNDI namespace.
         queue = (Queue) jndiContext.lookup(sendQueueName);
         // Create a QueueConnection from the QueueConnectionFactory
         queueConnection = queueConnectionFactory.createQueueConnection();
         // Start the QueueConnection.
         queueConnection.start();
         // Create a QueueSession object from the QueueConnection
         queueSession = queueConnection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
         // Create a QueueSender object for sending messages from the queue session.
         queueSender = queueSession.createSender(queue);
         // Prepare a message object from the queuesession.we will create a textMessage message object.
         message = queueSession.createTextMessage();
         // Set the message you want,to the message object.
         message.setText(textmsg);
         // Now we are ready to send the message.
         try {
            queueSender.send(message);
            System.out.println("The Message has been sent ");
         } catch (JMSException je) {
            System.err.println("caught " + je);
            Exception e = je.getLinkedException();
            if (e != null) {
               System.err.println("linked exception: " + e);
            }
            System.out.println("The Message has not been sent ");
            return -1;
         }


The above code converts D©COR in the input to D©COR in the output. I would appreciate if anyone can tell what CCSID values I should be use in this pgm.

regards,
rb
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Fri Dec 07, 2007 3:02 pm    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20756
Location: LI,NY

You can use CCSID 1208 (UTF-8 ).
You need to set the CCSID on the message

Enjoy
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
RB
PostPosted: Fri Dec 07, 2007 4:06 pm    Post subject: Reply with quote

Acolyte

Joined: 23 May 2006
Posts: 56

Thanks for the reply.

But I am already using that in the code. I think the reading part is not working correctly. Though I have specified "ISO-8859-1" while reading the file, it is not coming correctly.

When I display the content in between (string buffer sb), I can see the extra bytes.

I am not sure whether this is the correct way or value to be used in the InputStreamReader. Any thoughts?

Regards,
RB
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Fri Dec 07, 2007 4:23 pm    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

So you appear, at least to my very very very very very brief glance, to have created a TextMessage properly.

This has nothing to do with how you are reading the message.

Does the message apear as a TextMessage on the remote side? Or something else?
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
RB
PostPosted: Fri Dec 07, 2007 4:32 pm    Post subject: Reply with quote

Acolyte

Joined: 23 May 2006
Posts: 56

Yes, it is coming as a proper text message with an extra byte (Â). And I can see that the code page is set to 1208 in the MQMD header. Should I be using some other encoding value?? Or is the handling in between (chars to string buffer and back to string) somehow affecting the byte stream??

Regards,
RB
Back to top
View user's profile Send private message
RB
PostPosted: Fri Dec 07, 2007 4:35 pm    Post subject: Reply with quote

Acolyte

Joined: 23 May 2006
Posts: 56

btw, I am running this in Unix, if at all that is going to make any diff!!
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Sat Dec 08, 2007 4:40 pm    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20756
Location: LI,NY

RB wrote:
Thanks for the reply.

But I am already using that in the code. I think the reading part is not working correctly. Though I have specified "ISO-8859-1" while reading the file, it is not coming correctly.

When I display the content in between (string buffer sb), I can see the extra bytes.

I am not sure whether this is the correct way or value to be used in the InputStreamReader. Any thoughts?

Regards,
RB

ISO-8859-1 is CCSID 819. I am not sure that this CCSID will support all of your special characters. You're better off keeping it all in CCSID 1208 (UTF-8 ) and setting the CCSID on the message...

Enjoy
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
RB
PostPosted: Mon Dec 10, 2007 2:58 pm    Post subject: Reply with quote

Acolyte

Joined: 23 May 2006
Posts: 56

Thanks guys for the reply.

I was not setting the CCSID correctly while putting the message. I was adding it as a property to the Hashtable, but that doesn't look like the right way.
Now I am setting it using the set int property on the message as given below.

Code:
msg.setIntProperty( "JMS_IBM_Character_Set", 819);


But again, when I am trying with CCSID value as 1208, it is not coming correctly. But with 819 I am able to retain the values correctly.

Thanks,
RB
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Mon Dec 10, 2007 3:31 pm    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20756
Location: LI,NY

RB wrote:
Thanks guys for the reply.

I was not setting the CCSID correctly while putting the message. I was adding it as a property to the Hashtable, but that doesn't look like the right way.
Now I am setting it using the set int property on the message as given below.

Code:
msg.setIntProperty( "JMS_IBM_Character_Set", 819);


But again, when I am trying with CCSID value as 1208, it is not coming correctly. But with 819 I am able to retain the values correctly.

Thanks,
RB

This may well be because the text you are populating the message with is CCSID 819 and not UTF-8 ...
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
ling_71_99
PostPosted: Tue Dec 11, 2007 8:11 am    Post subject: Try to read into byte[] instead of StringBuffer Reply with quote

Novice

Joined: 19 Nov 2007
Posts: 11
Location: Canada

Try to read it into byte[] first, then convert to String the encoding you want as following:

encoding = "Cp437"; // the code page you want

byte[] ebcdic = ....;
String reconsituted = new String( ebcdic, encoding );

Regards,
Michael
_________________
Mike
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » CCSID for Trademark
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.