The argument type of the CAST () function changes to return two different encodings for Chinese:
SELECT CAST (' kanji ' as VARBINARY) as [GB2312];
-Equivalent to cast (cast (N ' kanji ' as VARCHAR (4)) as VARBINARY)
SELECT CAST (N ' kanji ' as VARBINARY) as [UTF-8];
-Equivalent to cast (cast (N ' kanji ' as NVARCHAR (2)) as VARBINARY)
Return the result (binary type):
GB2312
0xbabad7d6
UTF-8
0x496c575b
The hexadecimal code can be obtained by the master.sys.fn_varbintohexsubstring () function. Such as:
SELECT master.sys.fn_varbintohexsubstring (0, 0xbabad7d6, 1,0) as [GB2312]--return string: Babad7d6
SELECT master.sys.fn_varbintohexsubstring (0, 0x496c575b, 1,0) as [UTF-8]--return string: 496c575b
Note:
The Master.sys.fn_varbintohexstr () function and master.sys.fn_varbintohexsubstring () can only be converted to a binary number that is not less than 2,147,483,647 (int), see: http ://www.cnblogs.com/gaizai/p/4001016.html
Use the cast () function of SQL Server to obtain two encodings of GB2312 and UTF8