dev/python/unicode.py

20 lines
514 B
Python
Raw Normal View History

2011-08-30 16:49:49 +04:00
declare
@ucs nvarchar(4000),
@utf varchar(8000),
@w varbinary(2),
@i int
set @ucs = N'яфя Åk Paço عوديهالشرموطةناناالشرموطةفاطمةالشرموطةليلىالسحاقيةهالة'
set @utf = ''
set @i = 1
while @i <= len(@ucs)
begin
set @w = (select utf8 from ucs2utf8 where ucs2 = unicode(substring(@ucs, @i, 1)))
if @w/256 != 0 set @utf = @utf + char(@w/256)
if @w-(@w/256)*256 != 0 set @utf = @utf + char(@w-(@w/256)*256)
set @i = @i + 1
end
print @utf