dev/python/unicode.py

20 lines
514 B
Python

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