This discussion is archived
8 Replies Latest reply: May 7, 2013 3:30 AM by 997436 RSS

Escaped Unicode Characters NOT working - Internationalization support

997436 Newbie
Currently Being Moderated
Hi Team,

I want to store the respective escaped unicode characters for the simplified chinese characters. The stored content is to be converted to actual simplified chinese characters and shown on browser or PDF file. When I hard code those escaped unicode characters in a program, it is working fine. But when I store it in a database; pull those esacaped unicode characters from database and try to convert them into actual simplified chinese characters, in order to show on a browser or PDF file, is not working (after converting using "UTF8", it is still displaying the escaped unicode characters whatever pulled from database not the expecting simplified chinese characters).

Can you please help me to know the reason behind this behavior (I am suspecting at database charset) and also help me to get any suggestions/guide lines/references of which meet this requirement?

Thank you in advance.

Best Regards,
Mallaiah Papinni
  • 1. Re: Escaped Unicode Characters NOT working - Internationalization support
    sybrand_b Guru
    Currently Being Moderated
    'My car doesn't work, please fix my car'

    I can not see your car. There is no information on your database (no four digit Oracle version, no information on characterset) and no information on your OS (no platform, no characterset).

    Will it be sufficient for you to wave my magic wand?

    ---------
    Sybrand Bakker
    Senior Oracle DBA
  • 2. Re: Escaped Unicode Characters NOT working - Internationalization support
    997436 Newbie
    Currently Being Moderated
    Database details
    ===============
    Oracle 11g (11.1.0.7.0)
    DB Charset & other Details:
    NLS_LANGUAGE: AMERICAN
    NLS_TERRITORY: AMERICA
    NLS_CHARACTERSET: AL32UTF8
    NLS_NCHAR_CHARACTERSET: AL16UTF16

    OS
    ===============
    Windows and AIX (in development environments, we are using windows 7 enterprise; in SIT, UAT and PROD environments, we are using AIX).
    Charset on Windows:
    Language for non-Unicode programs: English (United States)

    Charset on AIX:
    EN_US.UTF-8
    EN_US
    en_US.8859-15
    en_US.ISO8859-1
    en_US

    Note: Programming language we are using is "Java".
  • 3. Re: Escaped Unicode Characters NOT working - Internationalization support
    997436 Newbie
    Currently Being Moderated
    Hi sybrand_b,
    Actually, I am looking at different approaches in terms of ease of implementation, less cost, no maintenance problems and etc. Anyhow, I have gone through those approaches along with their respective pros and cons.

    Thanks for your earlier posting.

    Best Regards,
    Mallaiah Papinni
  • 4. Re: Escaped Unicode Characters NOT working - Internationalization support
    Sergiusz Wolicki (Oracle) Expert
    Currently Being Moderated
    Do you store the HTML-escaped characters, like '੓'? In such case, these characters are just ASCII text from Oracle perspective and your issue has nothing to do with the database character set.

    Also, you have not given any details about your "conversion" process.

    -- Sergiusz
  • 5. Re: Escaped Unicode Characters NOT working - Internationalization support
    997436 Newbie
    Currently Being Moderated
    I am storing these characters as character escapes of NCRs (numeric character references) format in the database. Obviously, these characters are treated as ASCII characters from Oracle (database) perspective. But when you retrieve these characters from database and try to display on a browser, these are automatically get converted into actual (chinese) characters on browser irrespective of your web page's (HTML document's) charset. That's all.

    You would need to configure the database with respective (unicode) charset in order to support the multilingual (chinese) characters.

    Thanks!

    Best Regards,
    Mallaiah Papinni

    Edited by: 994433 on Apr 24, 2013 4:18 AM

    Edited by: 994433 on Apr 24, 2013 4:19 AM
  • 6. Re: Escaped Unicode Characters NOT working - Internationalization support
    997436 Newbie
    Currently Being Moderated
    Hi,
    The problem related to inserting unicode (chinese) characters into Oracle databae (11g) using SQL scripts is solved. But, there is another problem came up while retrieving those characters from database and showing them in a web page. It is showing those characters as "?????????????????" instead of "预订证券投资咨询". Please find details given below.
    Database : Oracle 11g
    NLS_LANG in db: AMERICAN_AMERICA.UTF8
    Driver URL: jdbc:oracle:thin:@hostname:port:dbname
    Driver Class Name: oracle.jdbc.OracleDriver
    NLS_CHARACTERSET: AL32UTF8
    NLS_NCHAR_CHARACTERSET: AL16UTF16

    Table DESCRIPTIONS Structure:
    Name Null Type
    ==== =========
    PROD_KEY VARCHAR2(100)
    PROD_DESC NVARCHAR2(1000)

    JSP Header: <meta http-equiv="Content-Type" content="text/html; charset=utf-8">

    Java code snippet:
    ==========================================
    String connectionURL = "jdbc:oracle:thin:@hostname:port:dbname";
    Class.forName("oracle.jdbc.OracleDriver");
    Connection conn = DriverManager.getConnection (connectionURL,"username","password");
    Statement stmt = conn.createStatement();
    String query = "SELECT * FROM DESCRIPTIONS";
    ResultSet rs = stmt.executeQuery(query);
    String jaString = "";
    while (rs.next()) {
    jaString = rs.getString("PROD_DESC");
    }
    request.setAttribute("INVSEC", jaString);
    System.out.println("Description in simplified chinese="+jaString);
    ==========================================

    I am suspecting at database driver configurations where in we need to configure the unicode charset. If it is, please help me in configuring the charset with syntax. I am not sure about it.

    Thank you very much in advance.

    Best Regards,
    Mallaiah Papinni
  • 7. Re: Escaped Unicode Characters NOT working - Internationalization support
    Sergiusz Wolicki (Oracle) Expert
    Currently Being Moderated
    With this database character set configuration character storage should work fine. You should use VARCHAR2 in place of NVARCHAR2 but even with NVARCHAR2 it should work. Use:
    SELECT DUMP(prod_desc,1016) FROM descriptions
    to verify what binary codes are stored in the column.

    Also, you have specified the <META> tag. Try also the page directive:
    <%@page contentType="text/html;charset=utf-8" %>
    -- Sergiusz

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points