[Python-bugs-list] [ python-Bugs-485951 ] repr diff between string and unicode.

noreply@sourceforge.net noreply@sourceforge.net
Wed, 28 Nov 2001 04:56:27 -0800


Bugs item #485951, was opened at 2001-11-27 02:25
You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=485951&group_id=5470

Category: Unicode
Group: None
>Status: Closed
>Resolution: Fixed
Priority: 3
Submitted By: Finn Bock (bckfnn)
Assigned to: M.-A. Lemburg (lemburg)
Summary: repr diff between string and unicode.

Initial Comment:
A minor difference exists between the repr output of 
string and unicode.

>>> "\x7f"
'\x7f'
>>> u"\x7f"
u'⌂'
>>>

I can't think of any reason for this difference.

----------------------------------------------------------------------

>Comment By: M.-A. Lemburg (lemburg)
Date: 2001-11-28 04:56

Message:
Logged In: YES 
user_id=38388

Ah, now I understand... I was misinterpreting the SF comment
which probably got passed through some HTML-quoting function.

You are right, \x7f should also be quoted. 
I'll fix that in CVS.

----------------------------------------------------------------------

Comment By: Finn Bock (bckfnn)
Date: 2001-11-28 04:34

Message:
Logged In: YES 
user_id=4201

I used 2.2b2. I had though the code in unicodeescape_string 
was at fault since it does:

        /* Map non-printable US ASCII to '\xhh' */
        else if (ch < ' ' || ch >= 128) {
            *p++ = '\';
            *p++ = 'x';
            *p++ = hexdigit[(ch >> 4) & 0x000F];
            *p++ = hexdigit[ch & 0x000F];
        }

where as string_repr does:

                else if (c < ' ' || c >= 0x7f) {
                        sprintf(p, "\x%02x", c & 0xff);
                        p += 4;

The 0x7F character is treated differently. I can't compile 
C programs at the moment so I cant verify this on the CVS 
version.

----------------------------------------------------------------------

Comment By: M.-A. Lemburg (lemburg)
Date: 2001-11-28 03:52

Message:
Logged In: YES 
user_id=38388

I can't reproduce this with the current CVS version of
Python on Linux.

Which version did you use ?


----------------------------------------------------------------------

You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=485951&group_id=5470