Currently command-line arguments to parrot programs come
in with a fixed_8 encoding.  I'd like to have those arguments
converted to (or treated as) utf8, so they can be evaluated as
unicode.  How do I do that?

Here's an example:

  .sub 'main' :main
      .param pmc args
      .local string str
      str = args[1]

      ##  ...CONVERSION GOES HERE...

      print "encoding = "
      $I0 = encoding str
      $S0 = encodingname $I0
      say $S0

      print "escape = "
      $S0 = escape str
      say $S0
  .end

This program takes the first argument from the command line and
displays its encoding and PIR escape sequence.  Here's a sample run:

  $ ./parrot x.pir '«☺»'
  encoding = fixed_8
  escape = \x{c2}\x{ab}\x{e2}\x{98}\x{ba}\x{c2}\x{bb}

If it gets mangled in email, the command line argument is:
    U+00AB LEFT-POINTING DOUBLE ANGLE QUOTATION
    U+263A WHITE SMILEY FACE
    U+00BB RIGHT-POINTING DOUBLE ANGLE QUOTATION

Here we can see that the command line argument has come in
as fixed_8 encoding.  I'd like that string to be somehow
treated as or converted to utf8/unicode instead, such that 
the output lines above would produce:

  encoding = utf8
  escape = \x{ab}\u263a\x{bb}

I've tried various combinations of trans_encoding and
trans_charset with little luck -- what magic am I missing?

Thanks!

Pm
_______________________________________________
http://lists.parrot.org/mailman/listinfo/parrot-dev

Reply via email to