From: Michal Suchanek Date: 2007-10-30T20:23:07+09:00 Subject: Re: \u escapes in string literals: proof of concept implementation On 29/10/2007, Nobuyoshi Nakada wrote: > Hi, > > At Mon, 29 Oct 2007 14:11:45 +0900, > David Flanagan wrote in [ruby-core:13032]: > > >> In a related matter, Should String.inspect be modified to support \u > > >> escapes? Perhaps when the primary encoding is not unicode it should do > > >> this? > > > > > > \x for other encodings? It means rb_encoding has to know which > > > escape to be used. > > > > > > > Hmm. I assumed that it would be the inspect method that generated the > > escapes, not the encoding objects. But yes, I was being Unicode-centric, > > since that is the only encoding we're considering a special escape for... > > Instead, how about to use \x for all encodings, with making > \x{...} to represent codepoint? No, please don't do that. How do you tell what you are looking at then? The string can be in pretty much any encoding that might or might not be displayed. I do not really know what is SJIS. Is it something like UTF-8 or UTF-16 with different encoding and different character (codepoint) set? I guess we can use something like \c or \c{} (or some other letter) for codepoint (which is only valid if the string encoding is specified somewhere). Using \x for bytes *and* codepoints would be quite confusing. \u should always designate an unicode codepoint. It is only valid if the string can be reasonably converted to unicode where "reasonably" is currently when all the other characters in the string are 7bit only. Thanks Michal