# Encoding.compatible? and dummy encodings

**URL:** <https://www.ruby-forum.com/t/encoding-compatible-and-dummy-encodings/125878>\
**Category:** Development\
**Created:** [January 13, 2008, 8:44am UTC](https://www.ruby-forum.com/t/encoding-compatible-and-dummy-encodings/125878 "2008-01-13T08:44:03Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![sheepman](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/d07c76/32.png) [@sheepman](https://www.ruby-forum.com/u/sheepman)\
**Post date:** [January 13, 2008, 8:44am UTC](https://www.ruby-forum.com/t/encoding-compatible-and-dummy-encodings/125878/1 "2008-01-13T08:44:03Z")

</div>

e$B$3$s$K$A$Oe(B sheepman e$B$G$9!#e(B

ISO-2022-JP e$B$JJ8;zNs$He(B EUC-JP e$B$JJ8;zNs$,e(B compatible e$B$He(B  
e$B$J$j$^$9$,$3$l$O0U?^$5$l$?$3$H$G$7$g$&$+!#e(B

dummy e$B%(%s%3!\<%G%#%s%0$@$H$3$&$$$&Iw$K$J$k$b$N$J$N$G$7$g$&$+!#e(B

$ cat t.rb  
#-_- coding: euc-jp -_-  
s = “e$B4A;ze(B”  
i = “e$B4A;ze(B”.encode(“ISO-2022-JP”)  
p Encoding.compatible?(s, i)  
p s + i

$ ruby-1.9 -v t.rb  
ruby 1.9.0 (2008-01-13 revision 0) [i686-linux]  
#Encoding:EUC-JP  
“e$B4A;ze(B\e$B4A;z\e(B”

---

<div class="post-metadata">

**Author:** ![sheepman](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/d07c76/32.png) [@sheepman](https://www.ruby-forum.com/u/sheepman)\
**Post date:** [January 13, 2008, 2:09pm UTC](https://www.ruby-forum.com/t/encoding-compatible-and-dummy-encodings/125878/2 "2008-01-13T14:09:17Z")

</div>

$B@.@%$G$9!#(B

sheepman wrote:

> p s + i
> 
> $ ruby-1.9 -v t.rb  
> ruby 1.9.0 (2008-01-13 revision 0) [i686-linux]  
> #Encoding:EUC-JP  
> “$B4A;z(B\e$B4A;z\e(B”

dummy encoding $B$@$+$i$G$O$J$/!“(B”\e$B4A;z\e(B" $B$,(B 7bit ASCII  
$B$NHO0O$K\<}(B  
$B$^$C$F$$$k$+$i$G$9$M(B (rb\_enc\_str\_asciionly\_p)$B!#(BISO-2022-JP  
$B$O\>o$K(B 7bit  
$B$J$N$G(B EUC-JP $B$@$1$G$J$/!"(BShift\_JIS $B$H$b(B UTF-8  
$B$H$b(B compatible $B$K$J$j$^$9!#(B

$B$3$l$I$&$7$^$7$g$&$+!#(BESC/SI/SO  
$B$,$"$C$?$i%@%a$H$+$G$7$g$&$+$M$'!&!&!&!#(B

---

<div class="post-metadata">

**Author:** ![sheepman](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/d07c76/32.png) [@sheepman](https://www.ruby-forum.com/u/sheepman)\
**Post date:** [January 14, 2008, 7:48am UTC](https://www.ruby-forum.com/t/encoding-compatible-and-dummy-encodings/125878/3 "2008-01-14T07:48:26Z")

</div>

e$B$^$D$b$He(B e$B$f$-$R$m$G$9e(B

In message “Re: [ruby-dev:33077] Re: Encoding.compatible? and dummy  
encodings”  
on Sun, 13 Jan 2008 22:08:18 +0900, “NARUSE, Yui”  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) writes:

|dummy encoding e$B$@$+$i$G$O$J$/!“e(B”\e$B4A;z\e(B" e$B$,e(B 7bit ASCII e$B$NHO0O$K\<}e(B  
|e$B$^$C$F$$$k$+$i$G$9$Me(B (rb\_enc\_str\_asciionly\_p)e$B!#e(BISO-2022-JP e$B$O\>o$Ke(B 7bit  
|e$B$J$N$Ge(B EUC-JP e$B$@$1$G$J$/!“e(BShift\_JIS e$B$H$be(B UTF-8 e$B$H$be(B compatible e$B$K$J$j$^$9!#e(B  
|  
|e$B$3$l$I$&$7$^$7$g$&$+!#e(BESC/SI/SO e$B$,$”$C$?$i%@%a$H$+$G$7$g$&$+$M$'!&!&!&!#e(B

dummye$B$Oe(Bcompatiblee$B$8$c$J$$$H$+!#e(B7bite$B$NHO0O$Ke(BESCe$B$r4^$a$J$$$H$+!#e(B  
e$B$I$C$A$,$$$$$+$J!#e(B

---

<div class="post-metadata">

**Author:** ![sheepman](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/d07c76/32.png) [@sheepman](https://www.ruby-forum.com/u/sheepman)\
**Post date:** [January 14, 2008, 9:48am UTC](https://www.ruby-forum.com/t/encoding-compatible-and-dummy-encodings/125878/4 "2008-01-14T09:48:17Z")

</div>

$B$J$+$@$G$9!#(B

At Mon, 14 Jan 2008 15:46:23 +0900,  
Yukihiro M. wrote in [ruby-dev:33084]:

> |dummy encoding $B$@$+$i$G$O$J$/!“(B”\e$B4A;z\e(B" $B$,(B 7bit ASCII $B$NHO0O$K\<}(B  
> |$B$^$C$F$$$k$+$i$G$9$M(B (rb\_enc\_str\_asciionly\_p)$B!#(BISO-2022-JP $B$O\>o$K(B 7bit  
> |$B$J$N$G(B EUC-JP $B$@$1$G$J$/!“(BShift\_JIS $B$H$b(B UTF-8 $B$H$b(B compatible $B$K$J$j$^$9!#(B  
> |  
> |$B$3$l$I$&$7$^$7$g$&$+!#(BESC/SI/SO $B$,$”$C$?$i%@%a$H$+$G$7$g$&$+$M$'!&!&!&!#(B
> 
> dummy$B$O(Bcompatible$B$8$c$J$$$H$+!#(B7bit$B$NHO0O$K(BESC$B$r4^$a$J$$$H$+!#(B  
> $B$I$C$A$,$$$$$+$J!#(B

$B8e\<T$O(BESC$B$G@ZBX$($,5/$3$k$b$N$G$J$$$H8z2L$,$J$$$N$G!"(BEBCDIC$B$J$I(B  
$B$r9M$($k$H0UL#$,$J$$$H;W$$$^$9!#(B

iso-2022-jp$B$H(BASCII$B$,$/$C$D$1$i$l$J$$$H$$$&$N$bHa$7$$$N$G!“(Bdummy  
$B$OF1$8$b$N$+(Bbase  
encoding$B$H$O(Bcompatible$B$H$7$?$$$H$3$m$G$9$,!”$d(B  
$B$O$j(BEBCDIC$B$J$I$N$h$&$K(BASCII  
compatible$B$G$J$$$b$N$r9M$($k$H!"$^$:(B  
$B$$$3$H$K$J$j$=$&$G$9!#$=$&$$$&$b$N$O!"(BASCII-8BIT$B$H$OJL$b$N$r%Y!\<(B  
$B%9$K$9$k$H$+$7$J$$$H$$$1$J$$$+$b!#(B

---

<div class="post-metadata">

**Author:** ![sheepman](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/d07c76/32.png) [@sheepman](https://www.ruby-forum.com/u/sheepman)\
**Post date:** [January 14, 2008, 9:25am UTC](https://www.ruby-forum.com/t/encoding-compatible-and-dummy-encodings/125878/5 "2008-01-14T09:25:16Z")

</div>

$B$3$s$P$s$O!"(Bsheepman $B$G$9!#(B

On Sun, 13 Jan 2008 22:08:18 +0900  
“NARUSE, Yui” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> dummy encoding $B$@$+$i$G$O$J$/!“(B”\e$B4A;z\e(B" $B$,(B 7bit ASCII $B$NHO0O$K\<}(B  
> $B$^$C$F$$$k$+$i$G$9$M(B (rb\_enc\_str\_asciionly\_p)$B!#(BISO-2022-JP $B$O\>o$K(B 7bit  
> $B$J$N$G(B EUC-JP $B$@$1$G$J$/!"(BShift\_JIS $B$H$b(B UTF-8 $B$H$b(B compatible $B$K$J$j$^$9!#(B

$B$J$k$[$I!“N;2r$7$^$7$?!#(B $B$”$j$,$H$&$4$6$$$^$9!#(B

---

<div class="post-metadata">

**Author:** ![sheepman](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/d07c76/32.png) [@sheepman](https://www.ruby-forum.com/u/sheepman)\
**Post date:** [January 14, 2008, 12:07pm UTC](https://www.ruby-forum.com/t/encoding-compatible-and-dummy-encodings/125878/6 "2008-01-14T12:07:24Z")

</div>

e$B$^$D$b$He(B e$B$f$-$R$m$G$9e(B

In message “Re: [ruby-dev:33089] Re: Encoding.compatible? and dummy  
encodings”  
on Mon, 14 Jan 2008 17:47:51 +0900, Nobuyoshi N.  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) writes:

|e$B8e\<T$Oe(BESCe$B$G@ZBX$($,5/$3$k$b$N$G$J$$$H8z2L$,$J$$$N$G!"e(BEBCDICe$B$J$Ie(B  
|e$B$r9M$($k$H0UL#$,$J$$$H;W$$$^$9!#e(B

EBCDICe$B$OEvLL9M$($J$/$F$b$h$$$H;W$$$^$9!#$I$&$+$s$,$($F$b@55,e(B  
e$BI=8=$H$+;H$($J$$$7!#e(B

---

<div class="post-metadata">

**Author:** ![sheepman](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/d07c76/32.png) [@sheepman](https://www.ruby-forum.com/u/sheepman)\
**Post date:** [January 14, 2008, 10:04am UTC](https://www.ruby-forum.com/t/encoding-compatible-and-dummy-encodings/125878/7 "2008-01-14T10:04:09Z")

</div>

$B@.@%$G$9!#(B

Yukihiro M. wrote:

> dummy$B$O(Bcompatible$B$8$c$J$$$H$+!#(B7bit$B$NHO0O$K(BESC$B$r4^$a$J$$$H$+!#(B  
> $B$I$C$A$,$$$$$+$J!#(B

ISO-2022-JP $B$G$b!“(B[\t\n\r !-~] $B$N$\_$J$i(B ESC  
$B$b=P$F$3$J$$$N$G!”$3$l$O(B  
ascii only  
$B$G$"$C$F$[$7$$$+$H!#$9$k$HA0\<T$G$OET9g$,0-$/$F!"8e\<T$K$J$j$=(B  
$B$&$G$9!#(B  
$BB\>$K(B 7bit $B$J%(%s%3!\<%G%#%s%0$O(B UTF-7  
$B$H$+$G$7$g$&$+!#$3$l$O$$$D$G$b7k9g(B  
$B2DG=$G$$$$$N$+$J$!!#(B

---

<div class="post-metadata">

**Author:** ![sheepman](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/d07c76/32.png) [@sheepman](https://www.ruby-forum.com/u/sheepman)\
**Post date:** [January 14, 2008, 2:04pm UTC](https://www.ruby-forum.com/t/encoding-compatible-and-dummy-encodings/125878/8 "2008-01-14T14:04:37Z")

</div>

At 18:03 08/01/14, you wrote:

> > |$B$^$C$F$$$k$+$i$G$9$M(B (rb\_enc\_str\_asciionly\_p)$B!#(BISO-2022-JP $B$O\>o$K(B 7bit  
> > $BB\>$K(B 7bit $B$J%(%s%3!\<%G%#%s%0$O(B UTF-7 $B$H$+$G$7$g$&$+!#$3$l$O$$$D$G$b7k9g(B  
> > $B2DG=$G$$$$$N$+$J$!!#(B

$B$=$b$=$b(B ISO-2022-JP $B$b(B UTF-7  
$B$bFbIt=hM}$N$?$a$K:n$i$l$F$J$$$7!“(B  
$BFbIt=hM}$K8~$$$F$J$$!#Nc$($P(B ISO-2002-JP  
$B$N\>l9g$K!“J8;zNs$r4JC1$K(B  
$B7k9g$9$k$K$O7h$^$j$,I,MW$G$9$,!”$=$&$$$&7h$^$j$O$”$j$^$;$s(B  
($B:n$j$?$$$H;W$($P:n$l$k$H;W$$$^$9$,(B)$B!#$G$b$=$N7h$^$j$r\<i$k$?$a$K(B  
$BJ8;zNs$N0lIt\<h$j=P$7$N$H$3$m$GBgJQ6lO+$7$J$$$H9T$1$J$$$G$9!#(B  
UTF-7 $B$bF1$8$G$9!#(B

$B@5$7$$J}8~@-$H$7$F!“$=$&$$$&(B Encoding  
$B$N\>l9g!”=hM}$r6K8BIT2DG=$K$9$k$N$O(B  
$BBEEv$@$H;W$$$^$9!#6K8B$K!"F~NO$H=PNO0J30$K$O;H$($J$/$F!“B\>$K2?$+(B  
$B=hM}$7$?$$\>l9g$K$O(B ($B\<+?.$,$”$k?M$O(B) binary $B$d(B ASCII  
$B$J$I$G=hM}$9$k$+!"(B  
$BJQ49$9$k$+$K$9$kJ}$,%Y%9%H$H;W$$$^$9!#(B

$B59$7$/$\*4j$$$7$^$9!#(B

#-#-# Martin J. Du"rst, Assoc. Professor, Aoyama Gakuin University  
#-#-# [http://www.sw.it.aoyama.ac.jp](http://www.sw.it.aoyama.ac.jp)[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![sheepman](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/d07c76/32.png) [@sheepman](https://www.ruby-forum.com/u/sheepman)\
**Post date:** [January 14, 2008, 2:52pm UTC](https://www.ruby-forum.com/t/encoding-compatible-and-dummy-encodings/125878/9 "2008-01-14T14:52:30Z")

</div>

e$B$^$D$b$He(B e$B$f$-$R$m$G$9e(B

In message “Re: [ruby-dev:33094] Re: Encoding.compatible? and dummy  
encodings”  
on Mon, 14 Jan 2008 22:04:15 +0900, Martin D.  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) writes:

|e$B$=$b$=$be(B ISO-2022-JP e$B$be(B UTF-7 e$B$bFbIt=hM}$N$?$a$K:n$i$l$F$J$$$7!“e(B  
|e$BFbIt=hM}$K8~$$$F$J$$!#Nc$($Pe(B ISO-2002-JP e$B$N\>l9g$K!“J8;zNs$r4JC1$Ke(B  
|e$B7k9g$9$k$K$O7h$^$j$,I,MW$G$9$,!”$=$&$$$&7h$^$j$O$”$j$^$;$se(B  
|(e$B:n$j$?$$$H;W$($P:n$l$k$H;W$$$^$9$,e(B)e$B!#$G$b$=$N7h$^$j$r\<i$k$?$a$Ke(B  
|e$BJ8;zNs$N0lIt\<h$j=P$7$N$H$3$m$GBgJQ6lO+$7$J$$$H9T$1$J$$$G$9!#e(B  
|UTF-7 e$B$bF1$8$G$9!#e(B  
|  
|e$B@5$7$$J}8~@-$H$7$F!“$=$&$$$&e(B Encoding e$B$N\>l9g!”=hM}$r6K8BIT2DG=$K$9$k$N$Oe(B  
|e$BBEEv$@$H;W$$$^$9!#6K8B$K!"F~NO$H=PNO0J30$K$O;H$($J$/$F!“B\>$K2?$+e(B  
|e$B=hM}$7$?$$\>l9g$K$Oe(B (e$B\<+?.$,$”$k?M$Oe(B) binary e$B$de(B ASCII e$B$J$I$G=hM}$9$k$+!"e(B  
|e$BJQ49$9$k$+$K$9$kJ}$,%Y%9%H$H;W$$$^$9!#e(B

e$B$&!\<$s!“$\*$C$7$c$kDL$j$G$9!#$H$9$k$H!Ve(Bdummye$B$Oe(Bcompatiblee$B$G$Je(B  
e$B$$!W$NJ}$,@52r$J$N$G$7$g$&$M!#$3$N\>l9g!”\<+J,\<+?H$H$Oe(B  
compatiblee$B$J$N$G$7$g$&$+!#e(B

---

<div class="post-metadata">

**Author:** ![sheepman](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/d07c76/32.png) [@sheepman](https://www.ruby-forum.com/u/sheepman)\
**Post date:** [January 14, 2008, 3:44pm UTC](https://www.ruby-forum.com/t/encoding-compatible-and-dummy-encodings/125878/10 "2008-01-14T15:44:21Z")

</div>

$B@.@%$G$9!#(B

> In message “Re: [ruby-dev:33094] Re: Encoding.compatible? and dummy  
> encodings”  
> on Mon, 14 Jan 2008 22:04:15 +0900, Martin D.  
> [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) writes:  
> |$B=hM}$7$?$$\>l9g$K$O(B ($B\<+?.$,$"$k?M$O(B) binary $B$d(B ASCII $B$J$I$G=hM}$9$k$+!"(B  
> |$BJQ49$9$k$+$K$9$kJ}$,%Y%9%H$H;W$$$^$9!#(B

$B$“!\<!”$J$k$[$I!"3N$+$K!#(B

Yukihiro M. wrote:

> $B$&!\<$s!“$\*$C$7$c$kDL$j$G$9!#$H$9$k$H!V(Bdummy$B$O(Bcompatible$B$G$J(B  
> $B$$!W$NJ}$,@52r$J$N$G$7$g$&$M!#$3$N\>l9g!”\<+J,\<+?H$H$O(B  
> compatible$B$J$N$G$7$g$&$+!#(B

$B\<+J,\<+?H$H$O(B compatible  
$B$K$7$J$$$H!"%U%!%$%k$+$i%P%C%U%!$KC`<!FI$_9~$`!"(B  
$B$J$s$F$H$-$K$:$C$3$1$^$9$M!#(B

buf = ‘’  
open(‘hoge.txt’, ‘r:iso-2022-jp’) do |f|  
until f.eof?  
buf += f.redpartial(4096)  
end  
end
