March 11, 2005 at 3:14 pm
Can anyone suggest why this code produces a strange bug? The function takes a string of integers, takes one int at a time, performs some basic math, and then gets the unicode character corresponding to the number. Finally, it returns a string of unicode characters.
It seems to work perfectly, until the 11th posiiton in the string, and even then it works unless that digit is 9. If the 11th number is 9, the function always returns the '?' character, when it should return the unicode char #132. On the 12th digit it seems to work normally again.
CODE:
WHILE (@i <= @intLength)
BEGIN
--Get next char, cast to int, multiply by position, add 33.
SET @intFactor = ((CAST(SUBSTRING(@strIntString, @i, 1)
AS TINYINT) * @i) + 33)
--Get the corresponding unicode char.
SET @uniChar = NCHAR(@intFactor) --(@intFactor)
SET @strOutput = (@strOutput + @uniChar) --Append.
SET @i = (@i + 1)
END
RETURN @strOutput
This one has me stumped. Any help would be much appreciated.
-Greg
March 12, 2005 at 11:34 pm
I tried the exact example that you described and got a unicode 132 back. Maybe more information would help. What is the string you are passing?
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply