[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: String Conversion



"I am having trouble..." Not very helpful to help you. Since you were doing BASE64, you probably already have some of this figured out. So, maybe you already got this stuff and it is something else you are having trouble with.

Translate to ASCII, translate the ASCII to hex, add 0x on front, translate back to EBCDIC?, send XML?

I think maybe you need this:
http://www.code400.com/forum/showthread.php/7047-Char-to-ASCII

It uses tables to do the translation (IBM says don't use those for new development) but should work for you. If you have the time, you could convert it to use iconv which Scott wrote about here:
https://www.ibm.com/developerworks/community/forums/html/topic?id=082ed87d-3407-4ee8-bb2c-5d5556a9a14d

There is iconv built-in to HTTPAPI so you shouldn't need to go that far actually. Here is a piece of code from the archives that does translation. I did not run it but you can see how it works. I am thinking http_SetCCSIDs should not be needed if translating from job to ASCII but you can play around a bit and see what you get. This one used http_xlatedyn. You might just want to use http_xlate or http_xlatep. http://www.scottklement.com/archives/ftpapi/201011/msg00034.html 

H DFTACTGRP(*NO) ACTGRP(*NEW) BNDDIR('HTTPAPI') DEBUG(*YES)             
                                                                        
D/copy libhttp/qrpglesrc,httpapi_h                                      
D Buffer          S             40A                                     
D size            S             10I 0                                   
D rc              S             10I 0                                   
D ReturnBufferptr...                                                    
D                 S               *                                     
D pReturnBuffer   S               *                                     
D ReturnBuffer    S            160A   Based(pReturnBuffer)              
D ConvertedLength...                                                    
D                 S             10I 0                                   
 /Free                                                                  
                                                                        
  http_debug(*ON); // Use default debug file...                         
                                                                        
  // Use UTF-8 character set - set up conversion from EBCDIC...         
                                                                        
  rc = http_SetCCSIDs(1208 : 277);                                      
  buffer = 'XYZÆØÅxyzæøå';                                              
  size = 20;                                                            
  dump;                                                                 
  rc = http_xlatedyn(size : %Addr(buffer) : TO_ASCII : ReturnBufferptr);
  if rc = -1;                       
    // Error handling...            
  else;                             
    ConvertedLength = rc;           
    pReturnBuffer = ReturnBufferptr;
  endif;                            
  dump;                             
  *inlr = *on;

-----Original Message-----
From: ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx [mailto:ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of Robin.Kresin@xxxxxxx
Sent: Wednesday, July 16, 2014 9:41 AM
To: ftpapi@xxxxxxxxxxxxxxxxxxxxxx
Subject: String Conversion

 All;


Our webservice requires out context field to be a byte array format - (ASCII Hex). 

I am having trouble converting to ASCII Hex on the iseries. 

It was Binary Base64 and then they  changed it. :(   Below is an example 
of the string before and after.
. 


File byteArray.txt shows what a Byte Array looks like.
File varchar.txt is what the byteArray.txt file looks like before converting it into Byte Array.

Robin

The information in this e-mail and any attachments is confidential and is intended solely for the attention and use of  ftpapi@xxxxxxxxxxxxxxxxxxxxxx.
If you are not the intended recipient, or person responsible for delivering this information to the intended recipient, please notify the sender immediately and destroy this e-mail and all copies of this e-mail on any storage mechanism.
Unless you are the intended recipient or his/her representative you are not authorized to, and must not, read, copy, distribute, use or retain this message or any part of it.
-----------------------------------------------------------------------
This is the FTPAPI mailing list.  To unsubscribe, please go to:
http://www.scottklement.com/mailman/listinfo/ftpapi
-----------------------------------------------------------------------