roxen.lists.pike.general

Subject Author Date
Re: GILD THE LILY? Martin Stjernholm <mast[at]lysator[dot]liu[dot]se> 15-04-2009
"PeterPan" <<zenothing[at]hotmail.com>> wrote:

> 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.

Ok, now I understand. That is a problem with the use of isprint(3) in
sprintf("%O", ...). It is actually locale dependent whether you get
that quoting or not, but if you got the utf-8 charset in your locale
it will get quoted.

sprintf("%O", ...) shouldn't really be locale dependent, because its
output might not go to the terminal. That'll be fixed. Anyway, the
principle is that %O should generate unambiguous output, which means
it should keep to the lowest common denominator, i.e. ascii.

Grubba and I discussed adding another one, %P, which doesn't quote
characters at all and hence might return widestring values. That'd be
nicer, if it's combined with a locale sensitive stdout, so that as
many characters as possible are output according to the locale
charset.

What you can do in the meantime is to reverse the \u quoting in the
write step instead, i.e. something like this:

  write ("%s", my_unquote (sprintf ("%O", my_value)));