2 Replies Latest reply on Aug 26, 2013 7:14 AM by thtsang

    UTL_FILE fonts


      Hello OTN,


      Need help to get some good formatting using UTL_FILE :

        vReport_FileName := DBMS_RANDOM.string('x',10) ;
        vFILE            := UTL_FILE.FOPEN('REPORT_FILES',vReport_FileName || '.txt','w');
        vEMPUnikey       := 0 ;
      vReportLine := 'Employee Issue Slip';
      vReportLine := '\n' || LPAD(' ',((60-LENGTH(vReportLine))/2)-1,' ') || vReportLine ;
      vReportLine := '-------------------' || '\n';


      Current output is :

                          Employee Issue Slip


      Date : 23-08-2013 01:48:45            Reference No.: 202  

      Code : RP01                                          S

      Name : RANJAN PAREKH                                 2   


      Barcode | Kapan        | Pkt  |  Sub   |   Pcs   | Amt    |


      300075  | KB           | 1    | 0      | 50      | 143.05 |


                       Total :| 1    |        | 50      |  143.05|


      My expected output is :in terminal fonts : like :

      Problem is : I'm not able to change the font please help

        • 1. Re: UTL_FILE fonts

          I'm afraid that I don't quite follow the question.


          You're generating a plain text file.  A plain text file does not have a font.  Whatever tool you are opening the file in will decide what font to use.  Some applications will use a fixed-width font, some will use a variable-width font by default.  Most will provide you with options to change the font that is used to display the text.


          If whatever application you are using to display the file supports either RTF or HTML, you could potentially use UTL_FILE to create a RTF or an HTML file that includes embedded font directives.


          Perhaps, though, you don't really mean "font".  Perhaps you are trying to output particular characters.  What is your database character set and what character set do you want the file encoded in?  The particular characters that you listed are not part of, say, the US7ASCII character set.  They almost certainly are part of the Unicode character set (AL32UTF8).  And they're probably part of many other character sets.



          1 person found this helpful
          • 2. Re: UTL_FILE fonts

            It's not different font. They are different characters. And whether they display correctly depends on the font.



            You are actually replacing some characters with others. The correct replacement requires considering characters in the corresponding column for up to 3 rows. You need to write (or copy) code to do the task. PL/SQL, while possible, may not be the best language. You also need to consider possible 'false positives' when writing such code (e.g., a minus sign under absolute value symbol).



            The best solution is to generate the text file with correct characters or correct formatting, or a generic markup that can be converted into other formats at will (e.g., docbook or xml)

            1 person found this helpful