5 Replies Latest reply on Mar 28, 2012 3:19 PM by Sergiusz Wolicki-Oracle

    Print Extended ASCII Codes in sql*plus

      how to print Extended ASCII Codes in sql*plus like if we use
      select chr(65)||chr(66)||chr(125) from dual; then output will be
      but if we use chr(127), chr(128) and so on then its do not print the correct result
      So please tell how we can get correct result in sql*plus

      Edited by: 922951 on Mar 23, 2012 2:26 AM
        • 1. Re: Print Extended ASCII Codes in sql*plus
          Srini Chavali-Oracle
          Pl post details of OS and database versions.

          Pl define what you mean by "correct result".

          CHR(127) is the 'delete' character (http://www.ascii-code.com/) - how do you plan to "output" or "print" it ?

          Pl post (using copy and paste) what you see when you execute your code. What exactly are you trying to achieve ?

          • 2. Re: Print Extended ASCII Codes in sql*plus
            Sergiusz Wolicki-Oracle
            There is really no such thing as extended ASCII codes.

            Computers use character set encodings to represent text data as bytes. On so-called ASCII platforms, most of these encodings (but not all), represent basic ASCII characters the same way as the ASCII standard does, i.e. as bytes (most precisely: octets) in the range 0-127, and use other possible byte values (128-255) to represent other characters. Depending on the encoding, one or more of these bytes may be used per character. There are encodings (East Asian) where a byte in the ASCII range may actually be a second byte of a multibyte character. Certain encodings, most notably UTF-16, use more than one byte for any character and, therefore, are not a binary superset of ASCII at all. Moreover, the code unit of UTF-16 is not byte (octet) but a 16-bit word ('ub2' in Oracle's C data type naming).

            Therefore, please rephrase your question and tell us what you really try to achieve.

            And do not post the same question twice in two threads!

            -- Sergiusz
            • 3. Re: Print Extended ASCII Codes in sql*plus
              In addition to what you have been asked to reveal above, please also provide:

              - version of Oracle Client and sql*plus if different from database server home

              - details of client environment from which sql*plus is run (even if it runs on the server host)

              - database character set. If it is a Utf-8 variant, CHR() might not work as you expect for input values > 127.
              • 4. Re: Print Extended ASCII Codes in sql*plus
                os is window xp
                version is oracle 10g

                want correct symbol in sql*plus which is given in this sidehttp://www.asciitable.com/ specially for Extended ASCII Codes..

                if i use through cmd then its print but in sql*plus its not getting print

                Thanx in advance
                • 5. Re: Print Extended ASCII Codes in sql*plus
                  Sergiusz Wolicki-Oracle
                  The mentioned web page uses some very outdated terminology from 1980-ties. The "Extended ASCII Codes", as they call it, are the upper codes of the MS-DOS (aka OEM) code page 437. There are many other OEM code pages available in Windows, where these codes are defined differently. Anyway, if you run SQL*Plus from Command Prompt, do this:

                  C:\> set NLS_LANG=AMERICAN_AMERICA.US8PC437
                  C:\> sqlplus ...
                  Assuming your database character set supports the particular characters your are interested in, this should help. You can check your database character set by running:
                  SELECT value FROM nls_database_parameters WHERE parameter='NLS_CHARACTERSET';
                  What is the result of this query in your database?

                  -- Sergiusz