mysql如何把16进制转换成中文字符显示

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了mysql如何把16进制转换成中文字符显示相关的知识,希望对你有一定的参考价值。

mysql遇到个blob字段,里边的内容是中文字符串,不知怎么还原出来
百度搜到hex,发现得到的是16进制数,请问把这个16进制数转成中文字符串显示出来,或者有什么一步到位的方法把blob转成中文字符串

参考技术A oracle的是这样的:
Oracle数据库中向BLOB类型字段插入字符串并把插入的BLOB数据转换成字符串显示的方法

首先先在数据库中创建一张表
create table TB_TEST
(
ID NUMBER,
BLB BLOB
)

其次向表中插入一条空数据
insert into tb_test (id,blb) values (1,empty_blob())

最后更改BLOB字段的值
declare
directions BLOB;
amount BINARY_INTEGER;
offset INTEGER;
first_direction VARCHAR2(100);
more_directions VARCHAR2(500);
begin
update set blb = empty_blob() where id = 1; --更新和新增一样要将BLOB字段设置为EMPTY_BLOB()
select blb into directions from tb_test where id = 1 for update; --一定要用for update锁住记录,否则
--DBMS_LOB.OPEN会出错
DBMS_LOB.OPEN(directions, DBMS_LOB.LOB_READWRITE);
first_direction := '这是我的第一个插入blob的数据,测试一下看一下效果如何,是否能够用pl/sql直接插到插入的数据值!';
amount := LENGTHB(first_direction); --number of characters to write
--有中文必须用LENGTHB
offset := 1; --begin writing to the first character of the CLOB
DBMS_LOB.WRITE(directions,
amount,
offset,
UTL_RAW.cast_to_raw(first_direction));
--UTL_RAW.cast_to_raw函数将字符串转换成二进制数
DBMS_LOB.CLOSE(directions);
commit;
end;

把插入的BLOB数据转换成字符串显示的方式是
select id,UTL_RAW.cast_to_varchar2(blb) blb from tb_test t;

这种方式在显示纯文本字符串时显示的是正常的,可当我插入的数据例如是<form id="form1" name="form1"><input type="data" value="hello"></form>这种时在查询显示时就会显示为空。本回答被提问者采纳

怎么把中文字符串转换成十六进制?

搜索内存的时候不知道代码 能不能把中文字符串转换成可以搜索的呢? (就像萝卜那个一样)

假设
dim strSMS as String
strSMS="我的昵称是iamben,欢迎大家来到我的VB.NET兴趣小组"
现在怎样才能将strSMS转换为unicode 后再转换为16进制的字符串呢?
Dim i As Integer
Dim j As Integer
Dim h As Integer
Dim strTmpSMS As String
i = Len(strSMS)
strTmpSMS = ""
For j = 1 To i
h = AscW(Mid(strSMS, j, 1))
If Abs(h) < 127 Then
strTmpSMS = "00" & Hex(h)
Else
strTmpSMS = Hex(h)
End If
GBToUnicode = GBToUnicode & strTmpSMS
Next
参考技术A 我有做好的 还带字符加密功能 只要你不输入密匙就是之间转16进制,分数有点少了吧 参考技术B //计算得到字符串的Unicode编码
static int getNumber(String str)

int temp=0;
for(int i=0;i<str.length();i++)

String substring=str.substring(i,i+1);
char[] c=substring.toCharArray();
String s=Integer.toHexString(c[0]);
int in=Integer.parseInt(s);
temp+=in;

return temp;
这是java写的代码。

以上是关于mysql如何把16进制转换成中文字符显示的主要内容,如果未能解决你的问题,请参考以下文章

String 和 16进制转换

C语言如何把11位16进制字符串转成16进制数?

C语言如何把11位16进制字符串转成16进制数?

labview 16进制字符串转换成10进制数值

js怎样把10进制数转换成16进制数显示?

C语言如何把11位16进制字符串转成16进制数?