This is not really a pull request, rather a question. Can this kind of incomplete implementation be merged in?
If no, I'm fine.
In my daily use of Rubinius, I need this before @brixen's full encoding support comes, because I often encounter characters outside Ascii.
If yes, I'll continue to work on this.
"a \0二\x7f\xe3\xc7\x61保護 b c".inspect
before: "a \x00\xE4\xBA\x8C\x7F\xE3\xC7a\xE4\xBF\x9D\xE8\xAD\xB7 b c"
"a \x00\xE4\xBA\x8C\x7F\xE3\xC7a\xE4\xBF\x9D\xE8\xAD\xB7 b c"
after: "a \u0000二\u007F\xE3\xC7a保護 b c" (same behavior with MRI 1.9 in this case)
"a \u0000二\u007F\xE3\xC7a保護 b c"
Why is the symbol :utf8 used here? Isn't the flag on toprint boolean?
This is just a mistake. I looked over it. In my original patch, the approach was more general envisioning to support for other encodings. But in the end, I realized the support isn't actually needed in this time. So I trimmed down the patch. This is the remnant of it....
By the way, in Japan, we finally almost moved to UTF-8. When we process non-UTF-8 strings, any sane system immediately encodes to it.
@ryoqun good news about the UTF-8. I'm fine with the patch but could you address the spec failures?
Add minimal encoding support to String#inspect
@brixen Thanks for accepting this! As I said before, I continued to work on fixing spec failures.
I think since we have more encoding stuff in place, this should be easier now. Looks like MRI's inspect uses Encoding.default_external if that is an ASCII compatible encoding (which UTF-8) is. We should probably do something similar for that for inspect then and use the current code for all the other encoding cases.
I'll work on this shortly.
@brixen Thanks. I'm really excited with the surge of commits for encoding support!
I've got this almost finished. I introduced a Character class so we can work with encoded strings on a character level and use methods like #ascii? or #printable? without putting those on String and dealing with collisions.
Fixed String#inspect for 1.9. Closes #1945.
Hooray! Thanks for correctly fixing this.
@ryoqun no problem, sorry it took so long! Slowly getting encoding completed.