16进制转换字符串函数
来源:互联网 发布:科科窝软件 编辑:程序博客网 时间:2024/05/29 08:32
/*
引自一位老外的文章,具体地址记不清了
--调用
declare @T1 nvarchar(4000)
,@tmp varchar(20)
set @T1=N'國'
select @tmp='0x'+substring(dbo.fn_hex_to_char(convert(varbinary(16),@T1),16),3,2)
exec('select convert(int,'+@tmp+')')
*/
CREATE function fn_hex_to_char (
@x varbinary(100), -- binary hex value
@l int -- number of bytes
) returns varchar(200)
as
-- Written by: Gregory A. Larsen
-- Date: May 25, 2004
-- Description: This function will take any binary value and return
-- the hex value as a character representation.
-- In order to use this function you need to pass the
-- binary hex value and the number of bytes you want to
-- convert.
begin
declare @i varbinary(10)
declare @digits char(16)
set @digits = '0123456789ABCDEF'
declare @s varchar(100)
declare @h varchar(100)
declare @j int
set @j = 0
set @h = ''
-- process all bytes
while @j < @l
begin
set @j= @j + 1
-- get first character of byte
set @i = substring(cast(@x as varbinary(100)),@j,1)
-- get the first character
set @s = cast(substring(@digits,@i%16+1,1) as char(1))
-- shift over one character
set @i = @i/16
-- get the second character
set @s = cast(substring(@digits,@i%16+1,1) as char(1)) + @s
-- build string of hex characters
set @h = @h + @s
end
return(@h)
end
- 16进制转换字符串函数
- 将16进制字符串转换为整数的函数
- Java的十六进制与字符串之间互相转换函数(16进制与String转换)
- 字符串转换成16进制字符串
- 字符串16进制转换
- strtol函数---将字符串按一定的进制转换
- java学习小记 输入输出 字符串 函数 高精度 进制转换
- Delphi的字符串与16进制的相互转换函数的汇编代码
- Java的16进制与字符串的相互转换函数
- delphi 中字符串与16进制、10进制转换函数
- Delphi下将字符串转换成16进制的小函数
- delphi 中字符串与16进制、10进制转换函数
- 每日一算法--java的16进制与字符串的相互转换函数
- VC支持十六(16)进制的字符串转换为数值函数strtoul
- 16进制数与字符串转换函数
- 字符串进制转换
- 字符串进制转换
- c 字符串转换函数
- 强制还原已存在的数据库
- 甜头未增压力增,美国工程师吐苦水
- STL(标准摸板库)
- Cocoon 的几个集成开发环境
- oralce学习笔记之视图篇
- 16进制转换字符串函数
- 构造函数--拷贝构造函数--析构函数
- BeginPaint-WINDOW API
- 莫名其妙
- PHP项目资源
- EndPaint-WINDOWS API
- 让IIS支持TOMCAT
- 异常类型 描述(C#)
- MSDN里的关于.net的PropertyGrid的使用和控件设计的文章。