From: Phillip Hutchings Date: 2006-06-23T06:36:54+09:00 Subject: Re: ascii representation of unicode string? > > > > could try: > > > > myAscii = s.unpack('U'*s.length).select{|x| x >46}.collect{|x| > > x.chr}.to_s > > Hello, > > This is fairly close to something I was trying earlier, except more elegant. > This seems to be munging my spaces though, as I take it the space code is > less than 46? Have to look for a chart. > > Is unpacking as UTF8 going to be problematic if the string is actually UTF16 > as Philip points out? > > I will play some more, thanks guys... > -d Spaces are 32 if I recall my ASCII. UTF-16 with no non-ASCII characters is essentially an ASCII string with NULLs every other byte, it's quite obvious. UTF-8 with only ASCII just looks like ASCII. -- Phillip Hutchings http://www.sitharus.com/