File tree Expand file tree Collapse file tree 1 file changed +13
-1
lines changed
src/main/java/org/truffleruby/core/encoding Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change 16
16
import com .oracle .truffle .api .library .ExportMessage ;
17
17
import com .oracle .truffle .api .strings .TruffleString ;
18
18
import org .jcodings .Encoding ;
19
+ import org .jcodings .specific .ASCIIEncoding ;
19
20
import org .jcodings .specific .USASCIIEncoding ;
20
21
import org .truffleruby .RubyContext ;
21
22
import org .truffleruby .core .kernel .KernelNodes ;
@@ -50,7 +51,18 @@ public final class RubyEncoding extends ImmutableRubyObjectNotCopyable
50
51
public RubyEncoding (Encoding jcoding , ImmutableRubyString name , int index ) {
51
52
assert name .getEncodingUncached () == Encodings .US_ASCII ;
52
53
this .jcoding = Objects .requireNonNull (jcoding );
53
- this .tencoding = Objects .requireNonNull (TStringUtils .jcodingToTEncoding (jcoding ));
54
+
55
+ TruffleString .Encoding tencoding ;
56
+ try {
57
+ tencoding = TStringUtils .jcodingToTEncoding (jcoding );
58
+ } catch (IllegalArgumentException e ) {
59
+ if (jcoding .isDummy ()) {
60
+ tencoding = TStringUtils .jcodingToTEncoding (ASCIIEncoding .INSTANCE );
61
+ } else {
62
+ throw e ;
63
+ }
64
+ }
65
+ this .tencoding = Objects .requireNonNull (tencoding );
54
66
this .name = Objects .requireNonNull (name );
55
67
this .index = index ;
56
68
You can’t perform that action at this time.
0 commit comments