How to handle special characters in unix

I have to implement a requirement where I construct a string separated by a special character, encrypt it and send it over to an external site. The program worked fine on my local machine (WL 9.2, JDK 5.0 on Windows). However, when moved to unix, the special character turned into ?. I searched and tried quite a lot of things but didnt find a solution. Has anybody encountered and resolved this issue?
public class MyTest {
          public static void main(String[] args) {
          try {
               String string1 = "abc";
               String string2 = "def";
               String string3 = "xyz";
               String string4 = "127.0.0.1";
               String sep = "?";
String sMessage = string1 + "\u00A6" + string2+ "\u00A6" + string3+ "\u00A6" + string4+ "\u00A6" + sUserID;
               String sMessage = string1 + "\u00A6" + string2+ "\u00A6" + string3+ "\u00A6" + string4+ "\u00A6" + sUserID;
               System.out.println("Message = " + sMessage);
               BlowfishMachine encryptor = new BlowfishMachine();
               String sMessageTx = encryptor.encryptMessage(sMessage);
               System.out.println("Encrypted Message = " + sMessageTx);
               BlowfishMachine decryptor = new BlowfishMachine();
               String[] splitStr = sMessageTx.split(";");
               String sMessageRx = encryptor.decryptMessage(splitStr[0], splitStr[1]);
               System.out.println("Decrypted Message = " + sMessageRx);
          } catch(Exception ex) {
               ex.printStackTrace();
          private static String getCurrentDate() {
               try {
                    SimpleDateFormat sdf = new SimpleDateFormat("dd/M/yyyy hh:mm:ss aa");
                    return sdf.format(new Date()).toString();
               } catch (Exception e) {
                    System.out.println("Convergys  :Problem getting System Date");
                    e.printStackTrace();
               return "abc";          
}

Sorry... hit the wrong key before I was done with the post!!!
I have to implement a requirement where I construct a string separated by a special character, encrypt it and send it over to an external site. The program worked fine on my local machine (WL 9.2, JDK 5.0 on Windows). However, when moved to unix, the special character turned into ?. I searched and tried quite a lot of things but didnt find a solution. Has anybody encountered and resolved this issue?
public class MyTest1 {
          public static void main(String[] args) {
          try {
               String string1 = "abc";
               String string2 = "def";
               String string3 = "xyz";
               String string4 = "127.0.0.1";
               String sMessage = string1 + "?" + string2+ "?" + string3+ "?" + string4;
               System.out.println("Message = " + sMessage);
               String sMessage1 = string1 + "\u00A6" + string2+ "\u00A6" + string3+ "\u00A6" + string4;
               System.out.println("Message = " + sMessage1);
          } catch(Exception ex) {
               ex.printStackTrace();
}This is the output I get on Windows:
Message = abc?def?xyz?127.0.0.1
Message = abc?def?xyz?127.0.0.1
This is what I get on Unix:
Message = abc?def?xyz?127.0.0.1
Message = abc?def?xyz?127.0.0.1

Similar Messages

  • How to handle special characters in NWDI

    Dear All
    I am trying to update the Description from JSP form. Through JCO we are calling the RFC of ABAP. We are passing these description from Java to RFC of ABAP and this RFC update the text in Database.
    We have noticed that if there is some special character in description like as : š or ž, complete description is not getting updated in to the SAP database.
    Can anyone help me how to handle these special characters in Java. There may be N number of special characters. We want to generalize it. We want to replace these characters by s and z respectively.
    For example : We want to update this description.
    APPLERR H'4301 H'FA03 H'254C na Zagreb TC4 riješen je cleaning procedurom, te je i kroz CSR odgovoreno da trap korekcija N01TCADG-0052 u bloku UPDC više nije potrebna, te se može izbaciti (AP143).
    Uspješno su završene HR17/CN-A3 FOA-e na tranzitnom nivou, te slijedi roll-out u dva termina 12/13.04 i 19/20.04. ETK je na sastanku isporučio SW, te ALEX i mini PLEX za sve objekte.
    AP147. Poslati finalnu dokumentaciju za uvođenje paketa (implementacijsku instrukciju i sve popratne datoteke).
    WHile updated text is as follows :
    APPLERR H'4301 H'FA03 H'254C na Zagreb TC4 rije
    N01TCADG-0052 u bloku UPDC vi
    Uspje
    sastanku isporu
    AP147. Poslati finalnu dokumentaciju za uvo
    Regards
    Bhavishya

    Hi Bhavishya,
    Apparently your SAP database isn't configured to support Unicode. That would be the first solution to your problem, but I can imagine it's a bit drastic to convert your DB.
    A second solution would be to encode the input description to ASCII before storing it in the database. When reading from the database, decode again to Unicode. This way, no information is lost. A suitable encoding would be Base64. e.g.
    String description = "šunday žebra";
    String descriptionBase64 = new sun.misc.BASE64Encoder().encode(
      description.getBytes("UTF-8")); // ""
    // store descriptionBase64 in the DB
    // later, when reading descriptionBase64 from the DB
    String description2 = new String(
      new sun.misc.BASE64Decoder().decodeBuffer(descriptionBase64), "UTF-8");
    Instead of using Sun's implementation, a better alternative is to use the open source implementation
    org.apache.commons.codec.binary.Base64 from Commons Codec . 
    The 3rd approach is indeed to normalize the description by replacing all special characters with their ASCII equivalent. A rather easy solution is as follows:
    String description = "šunday žebra";
    String descriptionNormalized = sun.text.Normalizer.normalize(
      description, sun.text.Normalizer.DECOMP, 0).replaceAll(
      "[^p{ASCII}]", "");
    sun.text.Normalizer decomposes the string, e.g. "éàî" becomes "e´a`i^", after which non-ASCII characters are being removed using a regular expression.Again, note that it's usually a bad idea to use sun.* packages, see note about sun.* packages. The above code only works with J2SE 1.4 and J2SE 5.0, but it breaks in J2SE 6.0 (where
    java.text.Normalizer became part of the public API ;-). A good open source implementation can be found here: ICU4J (com.ibm.icu.text.Normalizer). 
    Kind regards,
    /Sigiswald

  • How to handle special characters in Apex

    Hi ,
    In my application I have two regions - one is Report Region (Interactive Report) and other one is HTML region with two text items - Empno and name
    My Report has two columns Empno(varchar2) and Ename(varchar2).
    When I click the edit link in the report column, the empno should have a read only EMPNO value and ename is a text field with ENAME value.
    When I run my application I have encountered the following problems :
    1. if my empno has special characters like ' # ', the characters after that is not getting displayed
    2. if my empno has special characters like ',' - the characters after comma is treated as a next texitem value
    Here is my credential ,
    Workspace CTSAN_ORACLE_DB
    Username [email protected]
    Password lakshmi321
    URL : http://apex.oracle.com/pls/apex/f?p=9444:19:4292839314890159:::::
    Plz. suggest me how to rectify the above problems.
    Thanks,
    Anoo..
    Edited by: Anoo on Aug 13, 2010 3:05 AM

    Don't pass data values in URLs. Whilst it is possible to escape values to make them URL- and APEX parameter-safe, it is much better practice to avoid the problem altogether.
    Create a surrogate primary key on the table that is an immutable discrete numeric identifier and only use this as a URL parameter. In target pages/regions, use this PK value to retrieve the required data from the table.

  • How to Handle Special Characters in PI7.1

    Hi Team,
    I need to handle some special characters like <,>,& etc.. from WS Adapter to CRM in PI 7.1.
    http://www.sdn.sap.com/irj/scn/weblogs?blog=/pub/wlg/9420 [original link is broken]
    By using the above blog i had implemented the Java Code as
    public void execute(InputStream in, OutputStream out){
    try{
    int read_data;
    while((read_data = in.read()) != -1){
    if (read_data == '&'){
    out.write("&amp;".getBytes());
    }else if (read_data == '>'){
    out.write("&gt;".getBytes());
    }else if (read_data == '<'){
    out.write("&lt;".getBytes());
    }else if (read_data == '/'){
    out.write("&frasl;".getBytes());
    }else if (read_data == '\''){
    out.write("&apos;".getBytes());
    else { out.write(read_data);
    out.flush();
    } catch (Exception e){}
    I had added this class file in Operational Mapping.
    It is working  if we have only one IF condition for & in while
    Any suggestion
    Thanks
    Sriram

    Hi Ramesh,
    Thanks for your inputs, I have tried your code but it is not working. The error message stays the same.
    Dear Stephane,
    To describe the error more, the requirement is the payload coming from source through WS Adapter consists of the special characters <, > , & which are basic sematics of XML syntax. I need PI to process this payload with special characters and successfully transfer it to target CRM system. I have created the Java class with code (ref: Blog 9420) as stated earlier and added this class to my existing Operation Mapping. I am expecting the java mapping to replace the special characters in payload like  < with "&gt;" . So as the case with the other characters >,&,'
    After activaton of my operation mapping, I triggered the test message with Soap UI client and I could able to get a successful mapping only When I put the logic for &ampersand symbol only. However when I am trying to add the logic for > or < or ' the mapping is failing . I am using UTF-8 encoding across the source and PI enviroments.
    Sample SOAP message :
    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:abcabca.com">
       <soapenv:Header/>
       <soapenv:Body>
          <urn:MT_ABCDEFG_Req>
         <activity>
              <id/>
              <type>ZEMA</type>
              <actionType>C</actionType>
              <firewall>10000003</firewall>
              <subject>small &gt; &lt; attachment test</subject>
              <location/>
              <startDate>2010-07-08T10:53:31.000Z</startDate>
              <endDate>2010-07-08T10:53:31.000Z</endDate>
              <mainClient>1000319</mainClient>
              <mainContact>1000003</mainContact>
              <isConfidential>false</isConfidential>
              <summary/>
              <fullText>test body  - small.txt</fullText>
              <owner>1000021</owner>
              <from>ABCDEDF</from>
              <sendTo>emailaddress</sendTo>
              <copyTo/>
              <keywords/>
              <referenceId/>
              <createdBy>1000021</createdBy>
              <additionalContacts/>
              <additionalClients/>
              <additionalParticipants/>
              <status>A0008</status>
              <attachments>
                   <fileUrl>20100708110053-XXXXXXXXX</fileUrl>
                   <fileName>small.txt</fileName>
              </attachments>
              <attachments>
                   <fileUrl>20100708110053-XXXXXXXXX</fileUrl>
                   <fileName>EMail 2010-07-08.pdf</fileName>
              </attachments>
         </activity>
          </urn:MT_ABCDEFG_Req>
       </soapenv:Body>
    </soapenv:Envelope>
    Output on the SOAP UI  client for the above request:
    <!--see the documentation-->
    <SOAP:Envelope xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/">
       <SOAP:Body>
          <SOAP:Fault>
             <faultcode>SOAP:Server</faultcode>
             <faultstring>Server Error</faultstring>
             <detail>
                <s:SystemError xmlns:s="http://sap.com/xi/WebService/xi2.0">
                   <context>XIAdapter</context>
                   <code>ADAPTER.JAVA_EXCEPTION</code>
                   <text>com.sap.engine.interfaces.messaging.api.exception.MessagingException: com.sap.engine.interfaces.messaging.api.exception.MessagingException: XIServer:NO_MAPPINGPROGRAM_FOUND:
         at com.sap.aii.adapter.soap.ejb.XISOAPAdapterBean.process(XISOAPAdapterBean.java:1160)
         at sun.reflect.GeneratedMethodAccessor342.invoke(Unknown Source)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:585)
         at com.sap.engine.services.ejb3.runtime.impl.RequestInvocationContext.proceedFinal(
    What do you think where I am doing the wrong?
    Sriram

  • How to handle special characters in SQL statements

    How do you handle special charactes in a SQL statement? Here is an example:
    update table
    set notefield = 'This is Waldo's note'
    where keyfield = 7;
    Because the database connectivity vi accepts a string datatype wire, the ' in Waldo's note is seen as the end of string and an error is generated.
    Is there a way to tell labview that the ' is part of the string and not the string delimiter?
    Waldo

    If two single quotes don't work, try backslash single quote, like \'
    The backslash is often used as an escape character, meaning to treat the next character literally.
    - tbob
    Inventor of the WORM Global

  • How to handle special characters in Stage web view with Load URL method?

    Hi,
      I have Latin special characters in my text. My HTML content contains the text as well as the image. If I use stage webview LoadString,  images will not be displayed. But my latin characters are displayed correctly.
    If I use LoadURL method, the images are displayed correctly but I have problem in displaying the latin special characters. How to solve this issue?

    Don't pass data values in URLs. Whilst it is possible to escape values to make them URL- and APEX parameter-safe, it is much better practice to avoid the problem altogether.
    Create a surrogate primary key on the table that is an immutable discrete numeric identifier and only use this as a URL parameter. In target pages/regions, use this PK value to retrieve the required data from the table.

  • How to handle special characters such as apostrophe, ampersant

    Hello All,
    Tools:
    JSP, JSDK 2
    Oracle 8
    Issue:
    If the user supplies a String value inside a text box which has special characters such as apostrophe, while we try to compare that string with some value in the database, the sql error comes up as the sql string will be broken.
    Example:
    input string--> ABC D'OLL
    sql --> "select * from verndor where vendor_name ='ABC D'OLL' "
    Present solution:
    I am reading each input string & look for such special characters. if so, replaces that character with escape character + that character.
    This solution works.
    Problem:
    If there any more efficient way to handle such character??
    At java level or Database level
    Thanks In advance :)

    Use PreparedStatements

  • How to handle special characters in metadata?

    I have an implementation in C# to call ACS webservices for a long time. Last week we realized that some special characters in metadata fields are making the package request to not work. Example characters: éë. The response from ACS contains E_ADEPT_DISTRIBUTOR_AUTH. If we remove the special character, the request works as expected.
    I know that characters are working in the jar application but we can't manage to make them work from our C# application.
    Any help is welcome.

    Doing a SHA1-HMAC is relatively simple and there are only two inputs, the key and the message.
    Since you say this works correctly with lower ascii characters, but not with Unicode characters then I would assume you have the key correct and the only thing that is different is the message.  Also since it works correctly with lower ascii characters then you have the  XML infoset serialization correct, so assuming a similiarly sized message (ie take one character and replace with a unicode character), then your problem is going to be in the character encoding.
    I would suggest some healthy paranoia about this, by verifying that the byte stream being hashed is indeed correctly UTF8 encoded by looking at the hex values  (breakpoint in the SHA1-HMAC code) and comparing to a UTF8 table such as  http://www.utf8-chartable.de.

  • FTP ADAPTER: How to handle Special characters

    Hi All,
    We are running into issues with special characters while fpt'ing the file using FTP adapter.
    ex: japanese characters '東邦チタニウム株式会社' would look as '???????????' in the transferred file.
    The following steps are involved in the process.
    1. Reads the data from a database.
    2. Constructs an XML object.
    3. Transforms the data into ftp msg.- In this step the spl. characters are fine
    4. FTP's the msg.
    5. The file on FTP server has issues.
    Tried to change the file type to binary, UTF-8 etc.. but nothing worked.
    Any help/pointers will be highly appreciated.
    Thanks in advance.

    Hi Bhavishya,
    Apparently your SAP database isn't configured to support Unicode. That would be the first solution to your problem, but I can imagine it's a bit drastic to convert your DB.
    A second solution would be to encode the input description to ASCII before storing it in the database. When reading from the database, decode again to Unicode. This way, no information is lost. A suitable encoding would be Base64. e.g.
    String description = "šunday žebra";
    String descriptionBase64 = new sun.misc.BASE64Encoder().encode(
      description.getBytes("UTF-8")); // ""
    // store descriptionBase64 in the DB
    // later, when reading descriptionBase64 from the DB
    String description2 = new String(
      new sun.misc.BASE64Decoder().decodeBuffer(descriptionBase64), "UTF-8");
    Instead of using Sun's implementation, a better alternative is to use the open source implementation
    org.apache.commons.codec.binary.Base64 from Commons Codec . 
    The 3rd approach is indeed to normalize the description by replacing all special characters with their ASCII equivalent. A rather easy solution is as follows:
    String description = "šunday žebra";
    String descriptionNormalized = sun.text.Normalizer.normalize(
      description, sun.text.Normalizer.DECOMP, 0).replaceAll(
      "[^p{ASCII}]", "");
    sun.text.Normalizer decomposes the string, e.g. "éàî" becomes "e´a`i^", after which non-ASCII characters are being removed using a regular expression.Again, note that it's usually a bad idea to use sun.* packages, see note about sun.* packages. The above code only works with J2SE 1.4 and J2SE 5.0, but it breaks in J2SE 6.0 (where
    java.text.Normalizer became part of the public API ;-). A good open source implementation can be found here: ICU4J (com.ibm.icu.text.Normalizer). 
    Kind regards,
    /Sigiswald

  • How to handle special characters in PL/SQL

    You know like for a carriage return.
    Edited by: Samuel411 on Nov 17, 2009 3:42 PM

    Hi,
    Any suggestions?Yes, please provide some details regarding:
    the PL/SQL procedureWhat is it, what is it meant to do?
    the thing fails. How does it fail?
    Always post a complete error message when 'it fails'.
    Also provide your DB-version as well
    (and ideally you'd top it off with an example).
    From what I can make of it you're trying to process some in-list that fails when you're passing more than one value?
    Read:
    http://tkyte.blogspot.com/2006/06/varying-in-lists.html
    http://asktom.oracle.com/pls/asktom/asktom.search?p_string=%22varying+in+list%22
    edit
    But since we've all been editing over here, I might be way off in the mean time ;-)
    Edited by: hoek on Nov 18, 2009 12:52 AM

  • Handle special characters in the attribute name

    Hi,
    I am generating different view element in WD application dynamically. How to handle special characters other than '-/ABCDEFGHIJKLMNOPQRSTUVWXYZ_0123456789'  for the attribute name dynamically?
    Thank you, in advance.
    Trupti

    Going with the obvious response - don't use them?
    if you're using dynamic code, there is no reason (other than debug support) to give your created elements any meaningful name.
    Just generate a GUID for each new element and use that.
    If you need to be able to later search for and update the element a simple lookup table of GUID to reference string should work reasonably well.
    Cheers,
    Chris

  • Handling special characters in XML

    Hi,
    I am using Oracle 10g 'XMLType' datatype to store XML files. Before storing I parse the XML document using Java Xerces Parser. If it parses successfuly, then I perform some business rule execution based on XML file which was parsed. So till this stage there is no problems. But when XML file contains some special characters like copy-paste of some description from MS-Word document into XML tags, then Xerces parser will parse such characters with out any exceptions, but while inserting XML document, Oracle database just throws exception saying unable to handle special characters.. So how to avoid such exceptions or silent such exceptions with any specific settings respect to XMLType datatype in 10g DB.
    Please advice!
    Arvind Patil - IN

    Monica--
    In XI 2.0, we've noticed a number of issues processing special characters, primarily caused by the version of JCO that we're running.  It sounds like SAP has spent some time in the past few months focusing on these errors, so make sure you're on the most recent patchlevels of all your middleware components, including any of the middleware libraries that BC uses. In XI, we had to update the 3 files that make up the RFC library and JCO library.  SDM couldn't update the libraries for us -- we had to manually move the files to the right place.
    Escaped XML characters like "&amp;" "&#34;" "&quot;" were fixed as of JCO 2.0.10 (the current patchlevel on AIX/UNIX), the special character "&apos;" is fixed in the next release, JCO 2.0.11, due out in a few weeks (hotfixes are available).  I don't know the equivalent versions on other platforms.  By default, XI 2.0 appears to have shipped with JCO 2.0.5.  I would expect many XI 3.0 users to also be affected.
    This may or may not apply to BC, because I don't know what BC uses to talk to SAP under the covers.
    --Dan King
    Capgemini

  • Time-dependent Vendor Master & Handling Special Characters

    Hi,
    I need to extract time-dependent Vendor Master.
    1. The data source for <b>0VENDOR</b> does not have fields to hold the valid date range.
    2. Does the Master data in R/3 for Vendors will hold the valid date range?
    3. The text for <b>0VENDOR</b> provides time-dependent, but how to map the <b>valid from</b> and <b>valid to</b> fields?
    Handling Special Characters:
    We are trying to extract data from Legacy system via DB Connect. The item text field consists of special characters. Of course in BW customization we can specify all the special characters to consider. But the special character we observed is 'square' symbol i.e. 'new line character' in Oracle. We are updating this to an ODS object. When looked at error log, observed that green light for the number of records transferred and updated, but finally when it load into ODS object and activates popping up the error message saying 'could not recognize special character'.
    Please help me getting the 2 issues resolved.
    Thanks in advance.
    Regards,
    Sudhakar.

    Hi Everyone,
    Thanks for inputs on Special characters issue...
    Finally resolved with below piece of code in the start routine:
    DATA: FLAG,
          OFF TYPE I,
          LEN TYPE I VALUE 1,
          ALLOWED_CHAR(95) VALUE
    '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ`~!@#$%^&*()-_=+ ' &
    'abcdefghijklmnopqrstuvwxyz:;<>,.?/|\{}[]"'''.
    CONSTANTS: C_CHAR VALUE '-'.
      LOOP AT DATA_PACKAGE WHERE NOT /BIC/ZI_DESC IS INITIAL .
        DO.
          IF DATA_PACKAGE-/BIC/ZI_DESC CN  ALLOWED_CHAR.
            REPLACE SECTION OFFSET SY-FDPOS LENGTH LEN OF
                    DATA_PACKAGE-/BIC/ZI_DESC WITH C_CHAR.
            FLAG = SPACE.
          ELSE.
            FLAG = 'X'.
          ENDIF.
          IF FLAG = 'X'.
            EXIT.
          ENDIF.
        ENDDO.
        MODIFY DATA_PACKAGE.
      ENDLOOP.
    if abort is not equal zero, the update process will be canceled
      ABORT = 0.
    I have seen the link sent by 'Eugene Khusainov' today. Thought putting my piece of code that may help others...
    Regards,
    Sudhakar.

  • How to remove special characters in xml

    Dear friends,
    How to remove the special character  from the xml. I am placing the xml file and  fetching through file adapter.
    The problem is when there is any special character in xml. i am not able to pass to target system smoothly.
    Customer asking schedule the file adapter in order to do that the source xml should not have any special charatcters
    How to acheive this friends,
    Thanx in advance.
    Take care

    Hi Karthik,
    Go throgh the following links how to handle special character
    https://www.sdn.sap.com/irj/scn/weblogs?blog=/pub/wlg/9420 [original link is broken] [original link is broken] [original link is broken]
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/502991a2-45d9-2910-d99f-8aba5d79fb42
    Restricting special characters in XML within XI..
    Regards
    Goli Sridhar

  • How to print Special Characters in Sap-Scripts

    How to print Special Characters in Sap-Scripts
    Thanks,
    Ravi

    Hi
    if u want print special characters we can use hot codes i.e '  '  (single inverted commas). in between these hot codes insert u r special characters.
    write    '    !@#$%^&*( )  '.
    for the above write statement output is
    output is   !@#$%^&*( )

Maybe you are looking for

  • Windows Vista home and Netweaver 7.0 installation

    Hi Experts, I am trying to install SAP Netweaver AS trail version downloaded from sdn in my laptop. Laptop(Windows vista home premium OS) is in very good configurtation but unfortunately i have not succeeded with that. Can some one guide me like step

  • Important Problem with floating toolbar !

    Hi all! I developed a plug-in using Acrobat 8 SDK. When I start acrobat 9.0, click any floating toolbar on which all tool buttons have been expanded,acrobat 9 will exist,but acrobat 8 is OK. This situation only happens when floating toolbar has some

  • So did anyone hack the iPad and made it work with Flash?

    Hello Dudes & Dudettes, I basically need to write a Flash game that would work through the Safari browser on the iPad. Did anyone try to re-write the Adobe iPhone packager and make it work for the iPad? I am curious... ? Also anyone  knows if it is p

  • Is it possible to reinstall a program from a dmg file(s)?

    Hello All A while back I made a dmg image copy of our final cut pro install disks as a back up measure. Well now we need to reinstall and I can't find the orig disks. How, and can we just drag the dmg files to the desktop and just open them and run?

  • Combining PDFs - simple and free

    is there a way to combine PDF files into a single PDF file? Looking for a free and/or Open source solution. Cheers, Noah