# Internal string storage and Encoding::Converter#convpath

**URL:** <https://www.ruby-forum.com/t/internal-string-storage-and-encoding-converter-convpath/189013>\
**Category:** Ruby\
**Created:** [May 22, 2010, 12:03am UTC](https://www.ruby-forum.com/t/internal-string-storage-and-encoding-converter-convpath/189013 "2010-05-22T00:03:23Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ptyler](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/7bcc69/32.png) [@ptyler](https://www.ruby-forum.com/u/ptyler)\
**Post date:** [May 22, 2010, 12:03am UTC](https://www.ruby-forum.com/t/internal-string-storage-and-encoding-converter-convpath/189013/1 "2010-05-22T00:03:23Z")

</div>

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  
=\> [[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 T.

---

<div class="post-metadata">

**Author:** ![ptyler](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/7bcc69/32.png) [@ptyler](https://www.ruby-forum.com/u/ptyler)\
**Post date:** [May 22, 2010, 3:39am UTC](https://www.ruby-forum.com/t/internal-string-storage-and-encoding-converter-convpath/189013/2 "2010-05-22T03:39:22Z")

</div>

2010/5/22 Patrick T. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> 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]]

---

<div class="post-metadata">

**Author:** ![ptyler](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/7bcc69/32.png) [@ptyler](https://www.ruby-forum.com/u/ptyler)\
**Post date:** [May 24, 2010, 7:00pm UTC](https://www.ruby-forum.com/t/internal-string-storage-and-encoding-converter-convpath/189013/3 "2010-05-24T19:00:18Z")

</div>

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 T.
