octave-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Octave-bug-tracker] [bug #39774] Support octal and hexadecimal sprintf


From: Mike Miller
Subject: [Octave-bug-tracker] [bug #39774] Support octal and hexadecimal sprintf escape sequences
Date: Mon, 12 Aug 2013 18:11:25 +0000
User-agent: Mozilla/5.0 (X11; Linux i686; rv:17.0) Gecko/20100101 Firefox/17.0

URL:
  <http://savannah.gnu.org/bugs/?39774>

                 Summary: Support octal and hexadecimal sprintf escape
sequences
                 Project: GNU Octave
            Submitted by: mtmiller
            Submitted on: Mon 12 Aug 2013 02:11:24 PM EDT
                Category: Octave Function
                Severity: 3 - Normal
                Priority: 5 - Normal
              Item Group: Matlab Compatibility
                  Status: None
             Assigned to: None
         Originator Name: 
        Originator Email: 
             Open/Closed: Open
         Discussion Lock: Any
                 Release: dev
        Operating System: Any

    _______________________________________________________

Details:

According to the Matlab documentation for fprintf and sprintf, the standard C
escape sequences for octal and hexadecimal literal characters are supported.

http://www.mathworks.com/help/matlab/ref/sprintf.html

For Octave, note that this is about handling the escape sequences in the
printf/fprintf/sprintf functions when the format string argument is given as a
single-quoted string.

The following three sprintf commands should all return the same string. This
is based on the Matlab documentation only, I would appreciate it if someone
were able to confirm these in Matlab.


s = sprintf ('Octave')
s = sprintf ('\117\143\164\141\166\145')
s = sprintf ('\x4f\x63\x74\x61\x76\x65')


Instead, Octave does the following:


>> s = sprintf ('Octave')
s = Octave
>> s = sprintf ('\117\143\164\141\166\145')
warning: unrecognized escape sequence '\1' -- converting to '1'
warning: unrecognized escape sequence '\1' -- converting to '1'
warning: unrecognized escape sequence '\1' -- converting to '1'
warning: unrecognized escape sequence '\1' -- converting to '1'
warning: unrecognized escape sequence '\1' -- converting to '1'
warning: unrecognized escape sequence '\1' -- converting to '1'
s = 117143164141166145
>> s = sprintf ('\x4f\x63\x74\x61\x76\x65')
warning: unrecognized escape sequence '\x' -- converting to 'x'
warning: unrecognized escape sequence '\x' -- converting to 'x'
warning: unrecognized escape sequence '\x' -- converting to 'x'
warning: unrecognized escape sequence '\x' -- converting to 'x'
warning: unrecognized escape sequence '\x' -- converting to 'x'
warning: unrecognized escape sequence '\x' -- converting to 'x'
s = x4fx63x74x61x76x65





    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?39774>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]