How to get Hex from varchar?

Showing 1-2 of 2 messages
How to get Hex from varchar? yanivc. 12/19/07 11:51 PM
Hi.
I have a table with nvarchar column.
I need to get from a single record from this column the
Hexdecimal value for each "Letter".
How can I do it?
I could not find the right function to do so.
The string not necesarilly in ASCII and can contain some
"special" characters and letters from different languages.
The Data Server is ASE 12.5.3 and the character set is UTF
8.
Thanks,
Yaniv
Re: How to get Hex from varchar? Bret Halford 12/20/07 8:53 AM
depends a little on what datatype you want for the output.

select convert(binary(n), column)

will get you a binary value (which ISQL displays as a string).

If you want that value to actually be in a string in ASE, you need to
go one step further

select bintostr(convert(binary(n),column))


1>
2>
3> create table z (a varchar(20))
4> go
1> insert z values ("abcxyz")
2> go
(1 row affected)
1> select convert(binary(20), a) from z
2> go

 ------------------------------------------
 0x61626378797a0000000000000000000000000000

(1 row affected)
1> select bintostr(convert(binary(20), a)) from z
2> go

 ----------------------------------------
 61626378797a0000000000000000000000000000

(1 row affected)