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
- Description updated (diff)
Sorry, miss-post to ruby-core.
- File 0001-io.c-conversion-from-bom-encoding.patch added
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
'
- File deleted (
0001-io.c-conversion-from-bom-encoding.patch)
nobu (Nobuyoshi Nakada) wrote:
Updated.
OK, commit please.
- 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]
- Backport changed from 1.9.3: UNKNOWN, 2.0.0: UNKNOWN to 1.9.3: REQUIRED, 2.0.0: REQUIRED
- 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)
- 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]
Also available in: Atom
PDF
Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0