Results 1 to 3 of 3

Thread: utl_file format

  1. #1
    Join Date
    Nov 2004
    Posts
    1

    utl_file format

    Hi Friends,

    I am opening the file using 'utl_file.fopen()' and writing
    text data into that.There is no issues as far as writing data into file.

    We have some data that contains special chars(other than english).Forexample we have data like this

    Prol López Mateos

    When i am writing this data into text file,It is getting printed as

    Prol López Mateos

    Here the character ó is getting printed as ó.

    After some invetigation,I found that it is happening becuase the ó is getting stored as multi byte character.The file opening is in ASCII format.When writing into the text file ,The two byte character is being treated as 2 single byte ascii characters.So it is printing two characters
    Ã and ³.

    The solution for this is opening file in 'UTF8' or any unicode format.After searching oracle documentation and other resources we got following info.

    When we are trying to read or write data (contains multi bytes),We have to use 'utl_file.fopen_nchar()'(available only on ORALCE-9i) instead of ordinary 'utl_file.fopen'.
    Similarly the data we are going to write into text file must be 'NVARCHAR2' or 'NCHAR' instead of 'varchar'.It is also said that,The oracle automatically opens file in unicode format when we use 'utl_file.fopen_nchar'.
    I modified our code and incorporate all those changes(NVARCHAR2,fopen_nchar and put_line_nchar).But still the problem is same and the output file is in ASCII format.
    In documentaion,It is mentioned that oracle automatically converts the file format based on the character data i am writing into the file.But it is not happening and
    output file is in ASCII format.

    I also tried with another way.Before writing text into output file,I converted into unicode string (by using UNISTR() function.But still the output file in ASCII format.
    I used another function
    CONVERT(string,source_char_set,dest_char_set).But the output file be in 'ASCII' format.

    I conclude that if I can open text file in 'UTF-8' format,The issue will be solved.But how to open a file in 'UTF-8' format instead of 'ASCII' format.Is there any way to specify encoding scheme while opening the file?

    The defaut character set of database I am using is 'UTF-8'

    Any help will be much appreciated.


    Thanks
    surya mohan

  2. #2
    Join Date
    Jun 2008
    Posts
    1
    Hi Surya I am facing the same issue . Have u got any solution for this

  3. #3
    Join Date
    Nov 2010
    Posts
    1

    utl file format

    Hi,

    Even I am facing the same issue. Please share the solution if anyone knows.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •