From: James Gray Date: 2009-04-13T22:52:25+09:00 Subject: [ruby-core:23193] Regexp Encoding I'm trying to document the Encoding Regexp objects receive for the m17n series on my blog. This is how I think it works: * A /�/ literal is given a US-ASCII Encoding if it contains only 7-bit characters * A /�/ literal receives the current source Encoding when it contains 8-bit characters * The old /u and /n style modifiers still work to force a UTF-8 or US- ASCII Encoding * A /�/ literal that would be US-ASCII due to the source Encoding or / n will be upgraded to ASCII-8BIT by hex, octal, control, meta, or control-meta byte escapes (as discussed in [ruby-core:23184]) * A /�/ literal will receive a UTF-8 Encoding if it includes \u escapes * Regexp objects constructed with Regexp::new() receive the Encoding of the String passed containing the regular expression Am I right so far? Am I missing any variations? Am I right that Regexp's favor US-ASCII because it maximizes their compatibility? It makes it so you can use them on any ASCII compatible String instead of just a String in the source Encoding, right? Thanks again for the help. James Edward Gray II