Details

    • Number of attachments :
      0

      Description

      In MRI 1.9,

      {'a' => 1}.inspect.encoding is UTF8. In JRuby --1.9, {'a' => 1}

      .inspect.encoding is ASCII-8BIT.

      Heuristically, if a hash contains string keys or a multibyte (not necessarily UTF8) string value, then MRI encodes in UTF8:

      {1 => 'бязоо'}

      .inspect.encoding #=> UTF8

      {'ascii' => 1}

      .inspect.encoding #=> UTF8

      {1 => non_utf8_multibyte_encoding}

      .inspect.encoding #=> UTF8

      If the hash contains no strings in the keys and no multibyte strings in values, then MRI also encodes in ASCII-8BIT:
      {}.inspect.encoding #=> ASCII-8BIT

      {1 => 2}

      .inspect.encoding #=> ASCII-8BIT

      {1 => 'ascii'}

      .inspect.encoding #=> ASCII-8BIT

      JRuby always encodes in ASCII-8BIT no matter what.

        Activity

        Hide
        Hiro Asari added a comment -

        I can't tell when this was fixed, but 1.6.5 behaves correctly.

        Show
        Hiro Asari added a comment - I can't tell when this was fixed, but 1.6.5 behaves correctly.

          People

          • Assignee:
            Hiro Asari
            Reporter:
            David Lee
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: