Skip navigation.

Trasliteration - Conversion of double/triple byte characters to single byte characters for various requirements

I recently came across a document where the requirement was to convert from triple/double byte characters to single byte characters to send it for export complaince check as the export compliance system can accept only single byte characters.
Basically the useful thing about this was they were using IBM ICU project(an open source project) for this process,so in a way making it more open to developers.
These were the pros and cons for IBM identified by them.
Pros
- No interface needed (written in Java, integrable in Oracle)
- High level of portability, flexibility and scalability
- No internal maintenance needed (open source project)
- License free (nonrestrictive use with commercial software)
Unicode standardization, converts from/to a lot of other encodings
Cons
- Extensive testing will be required.

Basically my purpose of writing this document is to provide you with some terms to google.

Step 1: Write a plsql wrapper to call the java .

create or replace package icu_translit is
function transliterate( p_str varchar2) return varchar2;
pragma restrict_references(transliterate,RNDS, RNPS, WNDS, WNPS);
end;
/
create or replace package body icu_translit is
function transliterate( p_str varchar2) return varchar2 as
language java name 'xxx.icu.transliterator.transliterate(java.lang.String) return java.lang.String';
end;
/

Step 2: Write a Java wrapper to call the translit functionality of ICU project
package xxx.icu;

import com.ibm.icu.text.Transliterator;

public class transliterator {
    private static Transliterator transInst =Transliterator.createFromRules("MyTranslit", "", Transliterator.FORWARD);
    public static String transliterate(String in) {
        if (in != null)
            return transInst.transliterate(in);
        else
            return "";
    }
}

check this feature out its really good.

select icu_translit.transliterate('सेन्गुप्त') from dual
sen'gupta

Links
User Guide : http://userguide.icu-project.org
Home page of the ICU project: http://www.icu-project.org/