dbTalk Databases Forums  

Re: Escaping international (unicode) characters in string

comp.databases.ms-sqlserver comp.databases.ms-sqlserver


Discuss Re: Escaping international (unicode) characters in string in the comp.databases.ms-sqlserver forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Erland Sommarskog
 
Posts: n/a

Default Re: Escaping international (unicode) characters in string - 05-29-2007 , 08:39 AM






Greg R. Broderick (usenet200705 (AT) blackholio (DOT) dyndns.org) writes:
Quote:
I am needing some way, in the SQL Server dialect of SQL, to escape unicode
code points that are embedded within an nvarchar string in a SQL script,
e.g. in Java I can do:

String str = "This is a\u1245 test.";
SELECT @str = 'This is a' + nchar(1245) + ' test'

Note here that 1245 is decimal. If you want to use hex code (which you
normally do with Unicode), you would do:

SELECT @str = 'This is a' + nchar(0x1245) + ' test'




--
Erland Sommarskog, SQL Server MVP, esquel (AT) sommarskog (DOT) se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pro...ads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinf...ons/books.mspx


Reply With Quote
  #2  
Old   
Erland Sommarskog
 
Posts: n/a

Default Re: Escaping international (unicode) characters in string - 05-29-2007 , 04:23 PM






Greg R. Broderick (usenet200705 (AT) blackholio (DOT) dyndns.org) writes:
Quote:
When there are more than one or two non-US-ASCII characters in the
string, this quickly becomes impractically unwieldy, thus my comment in
my original posting:
If the are in sequence, you could do:

convert(nvarchar, 0x34123512...)

although this is certainly not too funny as you have twitch the bytes
around.

Another solution to use something like Microsoft Visual Keyboard, and
simply put the actual characters there.


--
Erland Sommarskog, SQL Server MVP, esquel (AT) sommarskog (DOT) se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pro...ads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinf...ons/books.mspx


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.