roxen.lists.pike.general

Subject Author Date
Re: GILD THE LILY? PeterPan <zenothing[at]hotmail[dot]com> 13-04-2009
class VARINFO(mixed v)/*{{{*/
{
        string _sprintf(int t)
        {
                if(t=='O'||t=='s'){
                        string out="";
                        string s=sprintf("%O",v);
                        werror("s=%s\n",s);
                        for(int i=0;i<sizeof(s);i++){
                                if(i+3<sizeof(s)&&s[i]=='\'
                                                &&s[i+1]>='0'&&s[i+1]<='9'
                                                &&s[i+2]>='0'&&s[i+2]<='9'
                                                &&s[i+3]>='0'&&s[i+3]<='9'
                                  ){
                                       
out+=sprintf("%c",((s[i+1]-'0')*8+(s[i+2]-'0'))*8+(s[i+3]-'0'));
                                        i+=3;
                                }else 
if(i+1<sizeof(s)&&s[i]=='"'&&s[i+1]=='"'){
                                        i+=1;
                                }else{
                                        out+=sprintf("%c",s[i]);
                                }
                        }
                        return out;
                }
        }
}/*}}}*/
void main()
{
        write("%O\n",VARINFO((["大家好":1])));
}

$ pike varinfo.pike
s=([ /* 1 element */
  "547566555": 1
])
([ /* 1 element */
  "\u00e5\u00a4\u00a7\u00e5\u00ae\u00b6\u00e5\u00a5\u00bd": 1
])

You can see: we not need to decode \uxxxx, we got from sprintf("%O",v) is 
\ooo things.

The problem is pike will encode non-latin char return from _sprintf('O') in 
"\uxxxx", this action is after _sprintf (of Varinfo) return. My Varinfo code 
can do nothing about this.

--------------------------------------------------
From: "Martin Stjernholm" <<mast[at]lysator.liu.se>>
Sent: Monday, April 13, 2009 6:46 AM
To: "PeterPan" <<zenothing[at]hotmail.com>>
Cc: <<pike[at]roxen.com>>
Subject: Re: GILD THE LILY?

> "PeterPan" <<zenothing[at]hotmail.com>> wrote:
>
>> It not, see this, I add a werror before VARINFO return:
> /.../
>
> I still don't see that you decode \uxxxx style escapes anywhere. Hence
> they remain encoded.
>
> Maybe a werror between the sprintf("%O",v) and your escape decoder
> loop could prove enlightening.
>
>