Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Getting char() from a different character set?

Author  Topic 

aiken
Aged Yak Warrior

525 Posts

Posted - 2002-10-15 : 13:17:36
I'm writting a little HTMLDecode function (which I'll share on here), and so far it's working pretty nice. However, it would greatly simplifiy my life if I could get characters from the extended HTML character sets into a char(), or if someone can help me see another way.

For instance, given the escaped character – (charset 8879), I need to get an n-dash (-). Now, I can manually do this for every one of the common cahrset 8879 characters (and also the charset 10646 characters, which are 3 digits and always above 255). But that's ugly. Here's how I'm doing it for "normal" ascii characters now, which is far better than having a million "replace" functions:

select @siPos=PatIndex('%&#___;%',@vcResult)
WHILE @siPos>0
BEGIN
select @vcEncoded=substring(@vcResult,@siPos,6)
select @siChar=cast(substring(@vcEncoded,3,3) as smallint)
if @siChar<255
select @vcResult=replace(@vcResult,@vcEncoded,char(@siChar))
else
-- This is where we need to handle ISO 10646
select @vcResult=replace(@vcResult,@vcEncoded,'')
select @siPos=PatIndex('%&#___;%',@vcResult)
END


Is it possible to get a character from another charset?

Thanks
-b

aiken
Aged Yak Warrior

525 Posts

Posted - 2002-10-15 : 15:53:02
Nevermind; got it. NCHAR() works fine for both unicode and non-unicode values. I've posted my little HTMLDecode script in the script library.

Cheers
-b

Go to Top of Page
   

- Advertisement -