Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight

Re^2: Japanese character in Linux

by prafulltc (Acolyte)
on Jul 07, 2011 at 14:14 UTC ( #913196=note: print w/replies, xml ) Need Help??

in reply to Re: Japanese character in Linux
in thread Japanese character in Linux

Thanx for reply.
We are using Oracle DB. We are using DBD::Oracle driver and data type of column where these data is stores id NVARCHAR. 
Oracle NLS_NCHAR enviroment variable is AL16UTF16.

Japanese character are inserted into Sybase DB table by some other tachnology and DBI is used for sybase conenctivity.My script is fetching from Sybase table.But not Japanese character are stored into variable.So first I need to know why not actual Japanese character are fetched
Post this what should be done to store these Japanese character into Oracle?. 


Replies are listed 'Best First'.
Re^3: Japanese character in Linux
by Corion (Patriarch) on Jul 07, 2011 at 14:20 UTC

    You need to check five things:

    1. In what encoding is the data stored in the Sybase database?
    2. Does your script Encode::decode the data from the proper encoding?
    3. In what encoding is the data stored in the Oracle database?
    4. Does your script Encode::encode the data to the proper encoding?
    5. Does your script output to the console in the encoding that the console uses?
      In Sybase Japanese data columns are encoded in Shift-JIS encoding.
      We are retrieving this data using DBI.
      use DBI qw(:sql_types);
       if ( @row = $dbFOX_sth->fetchrow_array ) {
                       ( $sInstrumentNameJ, $sInstrumentShortJ )    = @row;
      When we print this data in unix console it comes as junk.
      After we get this value in a variable we pass this to a stored proc which inserts data in Oracle Nvarchar2 data type field.
      Here it comes as inverted ?.
      Please advise.

        I guess, we'll have to go step by step. First, add "use Encode;". After you've obtained the values from DB, check if they are converted to internal perl encoding using

        print Encode::is_utf8($sInstrumentNameJ), "\n";
        If this produces "1", then the value is converted to perl's internal form and we should check how you output it to the terminal. If this produces empty string, then the value is not converted by the driver. In this case you have to convert it manually.

        In either case, we have to know which locale is active in your terminal emulator. Normally, it shall be some UTF-8 locale, but who knows. Please provide output of "locale" command.

        Also, if the "is_utf8" function produces empty string, it would be good to provide here the hexdump of the value you get from the database. Using this way for example

        print unpack("H*", $sInstrumentNameJ), "\n";
        And also the Japanese text it should correspond to.

        Please see points 2 to 5 of my reply.

Re^3: Japanese character in Linux
by mpeppler (Vicar) on Jul 19, 2011 at 09:27 UTC
    What is the charset of the Sybase server?
    Are the strings stored in univarchar() or in varchar() columns?

    If the charset is not set to utf8, and if the columns are not univarchar(), then you need to either have the client code (DBI/DBD::Sybase) use the utf8 charset when fetching the data, or use the same charset as the dataserver.

    If the data is stored in univarchar() columns then you should set your client charset to utf8.

    DBD::Sybase 1.12 should have better support for unicode/utf8 characters, btw.


Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://913196]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (4)
As of 2023-05-29 08:49 GMT
Find Nodes?
    Voting Booth?

    No recent polls found