webMethods

webMethods

Join this online group to communicate across IBM product users and experts by sharing advice and best practices with peers and staying up to date regarding product enhancements.

 View Only
Expand all | Collapse all

Conversion of Unicode characters to ASCII characters

  • 1.  Conversion of Unicode characters to ASCII characters

    Posted Fri November 16, 2012 11:08 PM

    I am pulling data from an oracle database and inserting it into another oracle database using JDBC adapter services.

    Some of the fields that I am pulling from the source database have Unicode characters. Is it possible to convert these characters to ASCII characters? Is there a built-in service to achieve this?

    Thanks in advance.


    #Flow-and-Java-services
    #Integration-Server-and-ESB
    #webMethods


  • 2.  RE: Conversion of Unicode characters to ASCII characters

    Posted Mon November 19, 2012 06:17 PM

    you can just read it as String type, then use: pub.string:stringToBytes, it has parameter of “encoding”
    put ASCII there. Then save it back as bytes.


    #Integration-Server-and-ESB
    #webMethods
    #Flow-and-Java-services


  • 3.  RE: Conversion of Unicode characters to ASCII characters

    Posted Mon November 19, 2012 09:18 PM

    Thank you tongwang


    #Integration-Server-and-ESB
    #webMethods
    #Flow-and-Java-services


  • 4.  RE: Conversion of Unicode characters to ASCII characters

    Posted Tue November 27, 2012 11:25 PM

    The data still looks the same. I don’t see any errors either. Is there a way out?


    #Flow-and-Java-services
    #Integration-Server-and-ESB
    #webMethods


  • 5.  RE: Conversion of Unicode characters to ASCII characters

    Posted Tue November 27, 2012 11:37 PM

    The data still looks the same. I don’t see any error either. Is there a way out?


    #webMethods
    #Integration-Server-and-ESB
    #Flow-and-Java-services


  • 6.  RE: Conversion of Unicode characters to ASCII characters

    Posted Wed November 28, 2012 12:42 AM

    Java strings always store the data using UTF-8.

    When moving between a string and a byte array (via stringToBytes or bytesToString) you specify the encoding to use in the byte array. E.g. for stringToBytes you indicate what encoding is desired for the resulting byte array. For the other direction, you specify what encoding the byte array uses so that it can be properly interpreted.

    Whether or not a Unicode character has an ASCII equivalent depends upon the specific character and the mapping that Java does for the different encodings.

    How are you checking that the “data still looks the same?” Can you provide more detail about the steps you’re performing?


    #Flow-and-Java-services
    #Integration-Server-and-ESB
    #webMethods


  • 7.  RE: Conversion of Unicode characters to ASCII characters

    Posted Wed November 28, 2012 12:51 AM

    I am pulling the data (in unicode) as a string from the database using a select adapter service. I then use stringToBytes with ASCII as the encoding and then use bytesToString with encoding as ASCII to convert it back to a string and then insert it into the database via a batch insert adapter service.


    #webMethods
    #Integration-Server-and-ESB
    #Flow-and-Java-services


  • 8.  RE: Conversion of Unicode characters to ASCII characters

    Posted Wed November 28, 2012 12:53 AM

    After inserting the data into the target database, I am comparing it with the data in the source database and it looks unchanged.


    #Flow-and-Java-services
    #webMethods
    #Integration-Server-and-ESB


  • 9.  RE: Conversion of Unicode characters to ASCII characters

    Posted Wed November 28, 2012 05:00 PM

    Which characters are you expecting to be different?


    #Flow-and-Java-services
    #webMethods
    #Integration-Server-and-ESB


  • 10.  RE: Conversion of Unicode characters to ASCII characters

    Posted Thu November 29, 2012 11:02 PM

    After converting the required fields into ascii and pushing to the target database, I look at the data in the target database. The data is still the same and has not been converted into ASCII (I used a unicode to ASCII converter online to see the ASCII equivalent characters for the unicode characters)


    #webMethods
    #Flow-and-Java-services
    #Integration-Server-and-ESB