File tree Expand file tree Collapse file tree 2 files changed +23
-4
lines changed
core/src/main/java/org/jruby Expand file tree Collapse file tree 2 files changed +23
-4
lines changed Original file line number Diff line number Diff line change @@ -270,8 +270,15 @@ private final IRubyObject inspect19(Ruby runtime) {
270
270
271
271
RubyString str = RubyString .newString (runtime , result );
272
272
// TODO: 1.9 rb_enc_symname_p
273
- if (isPrintable () && isSymbolName19 (symbol )) return str ;
274
-
273
+ Encoding resenc = runtime .getDefaultInternalEncoding ();
274
+ if (resenc == null ) {
275
+ resenc = runtime .getDefaultExternalEncoding ();
276
+ }
277
+
278
+ if (isPrintable () && (resenc .equals (symbolBytes .getEncoding ()) || str .isAsciiOnly ()) && isSymbolName19 (symbol )) {
279
+ return str ;
280
+ }
281
+
275
282
str = (RubyString )str .inspect19 ();
276
283
ByteList bytes = str .getByteList ();
277
284
bytes .set (0 , ':' );
@@ -512,11 +519,11 @@ public int getLine() {
512
519
}
513
520
514
521
private static boolean isIdentStart (char c ) {
515
- return ((c >= 'a' && c <= 'z' )|| (c >= 'A' && c <= 'Z' ) || c == '_' );
522
+ return ((c >= 'a' && c <= 'z' )|| (c >= 'A' && c <= 'Z' ) || c == '_' || !( c < 128 ) );
516
523
}
517
524
518
525
private static boolean isIdentChar (char c ) {
519
- return ((c >= 'a' && c <= 'z' ) || (c >= '0' && c <= '9' ) || (c >= 'A' && c <= 'Z' ) || c == '_' );
526
+ return ((c >= 'a' && c <= 'z' ) || (c >= '0' && c <= '9' ) || (c >= 'A' && c <= 'Z' ) || c == '_' || !( c < 128 ) );
520
527
}
521
528
522
529
private static boolean isIdentifier (String s ) {
Original file line number Diff line number Diff line change
1
+ # encoding: utf-8
2
+
3
+ # https://github.com/jruby/jruby/issues/2896
4
+ if RUBY_VERSION > '1.9'
5
+ describe 'Symbol#inspect' do
6
+ it 'returns correct value' do
7
+ :"Ãa1" . inspect . should == ":Ãa1"
8
+ :"a1" . inspect . should == ":a1"
9
+ :"1" . inspect . should == ":\" 1\" "
10
+ end
11
+ end
12
+ end
You can’t perform that action at this time.
0 commit comments