[Tutor] Re: How to convert a hex value string into a real unicode?

Derrick 'dman' Hudson dman@dman.ddts.net
Mon, 23 Sep 2002 23:40:06 -0400


--XsQoSWH+UP9D9v3l
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Tue, Sep 24, 2002 at 12:43:18AM +0000, Hy Python wrote:
| Could you please tell me if it's possible to convert a hex value string=
=20
| into a real unicode?
|=20
| I mean that
| if   myHexStr=3D"5E74"
| then how can I convert myHexStr into a unicode which looks like u'u\5E74'=
 ?
|=20
| I understand that
| '5E74'+u'' returns u'5E74'
| but this is not what I want.
| I need u'\u5E74"

# obtained from some input, I assume
hs =3D "5E74"
# processing begins here
hs =3D '0x'+hs
unistr =3D unichr( int(hs) )

This method, as shown, only works for a single character.  It converts
the hex string to an integer, and from there to a unicode character
(or a unicode string of length 1, if you prefer).

-D

--=20
Failure is not an option.  It is bundled with the software.
=20
http://dman.ddts.net/~dman/

--XsQoSWH+UP9D9v3l
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iEYEARECAAYFAj2P3pYACgkQO8l8XBKTpRQU3gCfeqOdfRXBae7LTqiknvbXDXyf
E1EAoIKhTtxCXAXey5vWjjHdqHQR7Zzp
=QvBT
-----END PGP SIGNATURE-----

--XsQoSWH+UP9D9v3l--