Project

General

Profile

Actions

Backport #8323

closed

no conversion by "bom|utf-8"

Added by nobu (Nobuyoshi Nakada) almost 11 years ago. Updated almost 11 years ago.


Description

Mode spec in open and etc. accepts BOM-prefix UTF encoding, however if the external and internal encodings given there are same no conversion take place regardless the actual external encoding.
Since the encoding prefixed with "BOM" is not a real encoding, but just a fallback, the conversion should honor the detected encoding by BOM.


Files

Updated by nobu (Nobuyoshi Nakada) almost 11 years ago

  • Description updated (diff)

Sorry, miss-post to ruby-core.

Updated by nobu (Nobuyoshi Nakada) almost 11 years ago

  • File 0001-io.c-conversion-from-bom-encoding.patch added

A patch attached

Updated by naruse (Yui NARUSE) almost 11 years ago

The patch doesn't work on following case:

% ./ruby -e'IO.write"p","a";open("p","r:BOM|utf-8:utf-8"){|f|p f.read.size}'
-e:1:in read': code converter not found (UTF-8 to UTF-8) (Encoding::ConverterNotFoundError) from -e:1:in block in '
from -e:1:in open' from -e:1:in '

Actions #5

Updated by nobu (Nobuyoshi Nakada) almost 11 years ago

  • File deleted (0001-io.c-conversion-from-bom-encoding.patch)

Updated by naruse (Yui NARUSE) almost 11 years ago

nobu (Nobuyoshi Nakada) wrote:

Updated.

OK, commit please.

Actions #7

Updated by nobu (Nobuyoshi Nakada) almost 11 years ago

  • Status changed from Open to Closed
  • % Done changed from 0 to 100

This issue was solved with changeset r40462.
Nobuyoshi, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.


io.c: conversion from bom encoding

  • io.c (rb_io_ext_int_to_encs, parse_mode_enc): bom-prefixed name is
    not a real encoding name, just a fallback. so the proper conversion
    should take place even if if the internal encoding is equal to the
    bom-prefixed name, unless actual encoding is equal to the internal
    encoding. [ruby-core:54563] [Bug #8323]
  • io.c (io_set_encoding_by_bom): reset extenal encoding if no BOM
    found. [ruby-core:54569]

Updated by nobu (Nobuyoshi Nakada) almost 11 years ago

  • Backport changed from 1.9.3: UNKNOWN, 2.0.0: UNKNOWN to 1.9.3: REQUIRED, 2.0.0: REQUIRED
Actions #9

Updated by nobu (Nobuyoshi Nakada) almost 11 years ago

  • Tracker changed from Bug to Backport
  • Project changed from Ruby master to Backport200
  • Category deleted (M17N)
  • Status changed from Closed to Assigned
  • Assignee changed from naruse (Yui NARUSE) to nagachika (Tomoyuki Chikanaga)
  • Target version deleted (2.1.0)
Actions #10

Updated by nagachika (Tomoyuki Chikanaga) almost 11 years ago

  • Status changed from Assigned to Closed

This issue was solved with changeset r40541.
Nobuyoshi, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.


merge revision(s) 40462: [Backport #8323]

* io.c (rb_io_ext_int_to_encs, parse_mode_enc): bom-prefixed name is
  not a real encoding name, just a fallback.  so the proper conversion
  should take place even if if the internal encoding is equal to the
  bom-prefixed name, unless actual encoding is equal to the internal
  encoding.  [ruby-core:54563] [Bug #8323]

* io.c (io_set_encoding_by_bom): reset extenal encoding if no BOM
  found.  [ruby-core:54569]
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0