Skip to content

Instantly share code, notes, and snippets.

@cheald
Created January 22, 2015 22:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cheald/feff996b01f5937abfd7 to your computer and use it in GitHub Desktop.
Save cheald/feff996b01f5937abfd7 to your computer and use it in GitHub Desktop.
diff --git a/core/src/main/java/org/jruby/ast/SymbolNode.java b/core/src/main/java/org/jruby/ast/SymbolNode.java
index 747f28a..aa4d811 100644
--- a/core/src/main/java/org/jruby/ast/SymbolNode.java
+++ b/core/src/main/java/org/jruby/ast/SymbolNode.java
@@ -48,6 +48,7 @@ import org.jruby.runtime.Block;
import org.jruby.runtime.ThreadContext;
import org.jruby.runtime.builtin.IRubyObject;
import org.jruby.util.ByteList;
+import org.jruby.util.StringSupport;
/**
* Represents a symbol (:symbol_name).
@@ -67,9 +68,10 @@ public class SymbolNode extends Node implements ILiteralNode, INameNode {
public SymbolNode(ISourcePosition position, ByteList value) {
super(position);
this.name = value.toString().intern();
+
// FIXME: A full scan to determine whether we should back off to US-ASCII. Lexer should just do this properly.
- if (value.lengthEnc() == value.length()) {
- this.encoding = USASCIIEncoding.INSTANCE;
+ if (value.getEncoding().isAsciiCompatible() && StringSupport.codeRangeScan(value.getEncoding(), value) == StringSupport.CR_7BIT) {
+ encoding = USASCIIEncoding.INSTANCE;
} else {
this.encoding = value.getEncoding();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment