Index: /Users/ias/workspace/jruby/src/jregex/Pattern.java =================================================================== --- /Users/ias/workspace/jruby/src/jregex/Pattern.java (revision 3698) +++ /Users/ias/workspace/jruby/src/jregex/Pattern.java (working copy) @@ -32,6 +32,8 @@ import java.io.*; import java.util.*; +import org.jruby.util.ByteList; + /** * A handle for a precompiled regular expression.
* To match a regular expression myExpr against a text myString one should first create a Pattern object:
@@ -147,6 +149,14 @@
    * see REFlags
    */
    public Pattern(String regex, int flags) throws PatternSyntaxException{
+       if (flags == 2) {
+      try {
+        regex = new String(ByteList.plain(regex),"UTF8");
+    } catch (UnsupportedEncodingException e) {
+        // TODO Auto-generated catch block
+        e.printStackTrace();
+    }
+       }
       compile(regex,flags);
    }
    
Index: /Users/ias/workspace/jruby/src/org/jruby/RubyMatchData.java
===================================================================
--- /Users/ias/workspace/jruby/src/org/jruby/RubyMatchData.java	(revision 3698)
+++ /Users/ias/workspace/jruby/src/org/jruby/RubyMatchData.java	(working copy)
@@ -33,6 +33,8 @@
  ***** END LICENSE BLOCK *****/
 package org.jruby;
 
+import java.io.UnsupportedEncodingException;
+
 import jregex.Matcher;
 import org.jruby.runtime.Arity;
 import org.jruby.runtime.CallbackFactory;
@@ -282,7 +284,9 @@
             // JRUBY-97, but at the same time the testcase remained very slow
             // The additional minor optimizations to RubyString as part of the fix
             // dramatically improve the performance. 
-            return getRuntime().newString(matcher.group((int)n));
+    
+            return RubyString.newUnicodeString(getRuntime(), matcher.group((int)n));
+//            return getRuntime().newString(matcher.group((int)n));
         }
 
         public RubyString pre_match() {
@@ -319,6 +323,17 @@
         public IRubyObject doClone() {
             return new JavaString(getRuntime(), original, matcher);
         }
+        
+        public int matchStartPosition() {
+            int position = 0;
+            try {
+                position = matcher.prefix().getBytes("UTF8").length;
+            } catch (UnsupportedEncodingException e) {
+                // TODO Auto-generated catch block
+                e.printStackTrace();
+            }
+            return position;
+        }
     }
 
     public static final class RString extends RubyMatchData {