Conversion of Unicode characters to ASCII characters

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.

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.

Thank you tongwang

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

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

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?

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.

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

Which characters are you expecting to be different?

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)