MaMu
MaMu

Reputation: 1879

Encoding german characters

I need to import with load data some perl - generated files to oracle database. Perl-script get a webpage and write csv file.

Here a simplified script:

use File::Slurp;     
my $c= ( $user && $passwd )
        ? get("$protocol://$user:$passwd\@$url")
        : get("$protocol://$url");

    write_file("$VZ_GET/$FileTS.$typ.csv",$c);

Here a sample line from the webpage:

5052;97;Jan;Ihrfelt 5053;97;Jari;Honko 5121;97;Katja;Keitaanniemi 5302;97;Ola;Södermark 5421;97;Sven;Sköld 5609;97;Peter;Näslund 

Content of the webpage is saved in var $c.

Here a sample line of csv file:

5053;97;Jari;Honko

Here a load command:

LOAD DATA
INTO TABLE LIQA
TRUNCATE
FIELDS TERMINATED BY ";"
(
    LIQA_ANALYST_ID,
    LIQA_FIRM_ID,
    LIQA_ANALYST_FIRST_NAME,
    LIQA_ANALYST_LAST_NAME,
    LIQA_TS_INSERT  DATE 'YYYYMMDDHH24MISS'
)

Command SELECT * FROM NLS_DATABASE_PARAMETERS WHERE PARAMETER = 'NLS_CHARACTERSET'; returns AL32UTF8.

The generated csv file is recognized as UTF-8 Unicode text.

Anyhow I cant import german characters. In the csv file they are still correct. But it is not the case in the database.

I have also tried to convert $c like this:

$c = encode("iso-8859-1", $c); 

The generated csv file is stll recognized as UTF-8 Unicode text.

I have no clue how can I fix it.

Upvotes: 1

Views: 1347

Answers (1)

MaMu
MaMu

Reputation: 1879

I have solved it:

$c = decode( 'utf-8', $c );
$c = encode( 'iso-8859-1' , $c );

Upvotes: 1

Related Questions