From: darren kirby Date: 2006-06-23T06:32:10+09:00 Subject: Re: ascii representation of unicode string? --nextPart1229927.MlQh84HX6u Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline quoth the Chris Hulan: > darren kirby wrote: > > Hello all. > > > > I am unpacking some unicode strings from a binary file. I have a string > > like: > > > > "W\000M\000/\000T\000r\000a\000c\000k\000N\000u\000m\000b\000e\000r\000= \0 > >00\000\003" > > > > and I need to turn it into: > > > > "WM/TrackNumber" > > could try: > > myAscii =3D 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= =2E=20 This seems to be munging my spaces though, as I take it the space code is=20 less than 46? Have to look for a chart. Is unpacking as UTF8 going to be problematic if the string is actually UTF1= 6=20 as Philip points out? I will play some more, thanks guys... =2Dd =2D-=20 darren kirby :: Part of the problem since 1976 :: http://badcomputer.org "...the number of UNIX installations has grown to 10, with more expected..." =2D Dennis Ritchie and Ken Thompson, June 1972 --nextPart1229927.MlQh84HX6u Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.3 (GNU/Linux) iD8DBQBEmww6wPD5Cr/3CJgRAmICAJ0XGwObKIjRF3ybfPxENqqCHSnonQCcDVe7 jnVhFaJkX1AO9EsxQ5rTV3w= =rDSq -----END PGP SIGNATURE----- --nextPart1229927.MlQh84HX6u--