Why does sprintf generate a Null when sprinting extended character 253(decimal) in to a a string variable? i.e.
sprintf(s,"%s","ý");
Me again! Forgot to mention that I am using the C51 Compiler and the problem seems to occur in both uV1 and uV2 versions.
I don't know, but you're on pretty dodgy ground using string literals containing characters that aren't 'real' ASCII ie >127. Could you use: sprintf(buff,"%c",253); instead? Stefan
Thanks for the suggestion. Only problem is, I use the extended characters for "special" symbols (button shapes etc.) on an LCD and these could be part of a full text string. This is the reason I used the %s format rather than %c. e.g. "1234ý678" the result data string would be: 31,32,33,34,36,37,38 I used sprintf in my example, but it was passing the string as a parameter to a function that brought the problem out. It was coincidence that sprintf resulted in the same problem. As stated in my original thread, all the other extended characters work! Why is 253 so different? Steve
Try "blah\x0FDblah" instead of "blahýblah". Any character with code above 127 is not guaranteed to work. Hexadecimal and octal codes were designed for that. - mike
All, Thanks for the suggestions. First time I've used the Discussion Forum and it's been a great help! I have tried Mike's solution and that works. Andrew, yes it definitely put the hex value 0xFD in to the string. Drew, I entered the code using Alt 0253 (in uV2) or Alt 253 (in uV1). Steve
View all questions in Keil forum