Ticket #468 (closed bug: fixed)

Opened 6 years ago

Last modified 4 years ago

string encoding not saved in pbc

Reported by: NotFound Owned by:
Priority: major Milestone:
Component: core Version:
Severity: medium Keywords:
Cc: Language:
Patch status: Platform: all

Description (last modified by NotFound) (diff)

This example shows the problem caused by the unimplementation of the Encoding field of string constants in pbc files:

$ cat strings.pir
.sub main
  $S0 = "hello"
  show($S0)
  $S0 = unicode:"hello"
  show($S0)
  $S0 = utf8:unicode:"hello"
  show($S0)
  $S0 = utf16:unicode:"hello"
  show($S0)
  $S0 = ucs2:unicode:"hello"
  show($S0)
.end

.sub show
  .param string s
  print s
  $I0 = bytelength s
  print '('
  print $I0
  print "): "
  $I0 = encoding s
  $S0 = encodingname $I0
  say $S0
.end

$ ./parrot strings.pir
hello(5): fixed_8
hello(5): utf8
hello(5): utf8
hello(5): utf16
hello(5): ucs2
$ ./parrot -o strings.pbc strings.pir
$ ./parrot strings.pbc
hello(5): fixed_8
hello(5): utf8
hello(5): utf8
hello(5): utf8
hello(5): utf8

To adequately solve the problem and test it, the pir compilers must also be fixed.

Change History

  Changed 6 years ago by NotFound

  • description modified (diff)

  Changed 5 years ago by jkeenan

Problem confirmed as still persisting at r43148.

follow-up: ↓ 4   Changed 5 years ago by NotFound

Changed PBC format in r46822 to store the encoding together with the charset and flags. Ticket left open until having a good way to test this feature.

in reply to: ↑ 3   Changed 4 years ago by plobsing

  • status changed from new to closed
  • resolution set to fixed

Replying to NotFound:

Changed PBC format in r46822 to store the encoding together with the charset and flags. Ticket left open until having a good way to test this feature.

Added slightly modified testcase in r48987. modifications:

  • bytelength returns 10 for utf16 and ucs2
  • stdout needs to be normalized (using PIO encoding layer) to handle utf16 and ucs2 properly

With tests in place, this ticket can be closed.

Note: See TracTickets for help on using tickets.