Internal string storage and Encoding::Converter#convpath

P

Patrick Thomson

Hi, everyone:

In #rubyspec we were discussing whether the specifications are correct =
for Encoding::Converter's convpath method. Since MRI uses UTF-8 =
internally, the #convpath method shows that it converts to UTF-8 for an =
intermediate step:

Encoding::Converter.new('ascii','Big5').convpath
=3D> [[Encoding::US_ASCII, Encoding::UTF_8], [Encoding::UTF_8, =
Encoding::Big5]]

Is the fact that MRI uses UTF-8 for its intermediate steps between =
incompatible encodings an implementation detail, or is it desired Ruby =
behavior?

Thanks very much,
-- Patrick Thomson
 
T

Tanaka Akira

2010/5/22 Patrick Thomson said:
In #rubyspec we were discussing whether the specifications are correct for Encoding::Converter's convpath method. Since MRI uses UTF-8 internally, the #convpath method shows that it converts to UTF-8 for an intermediate step:

UTF-8 is not required:

% ruby -e 'p Encoding::Converter.new("euc-jp", "shift_jis").convpath'
[[#<Encoding:EUC-JP>, #<Encoding:Shift_JIS>]]
 
P

Patrick Thomson

For encodings that can be converted directly (like EUC-JP to SJIS), I =
understand that no UTF-8 internal storage is required. However, what =
about encodings that do require an intermediate step? Is the choice of =
UTF-8 as an intermediate representation an implementation detail?

Thanks,
-- Patrick Thomson


correct for Encoding::Converter's convpath method. Since MRI uses UTF-8 =
internally, the #convpath method shows that it converts to UTF-8 for an =
intermediate step:
=20
UTF-8 is not required:
=20
% ruby -e 'p Encoding::Converter.new("euc-jp", "shift_jis").convpath'
[[#<Encoding:EUC-JP>, #<Encoding:Shift_JIS>]]
--=20
Tanaka Akira
=20
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top