What encoding should I use to encode temperautre symbol in my iOS development?

StackOverflow https://stackoverflow.com/questions/13898299

  •  09-12-2021
  •  | 
  •  

سؤال

char symbol[] = {0xa1,0xe3};  //temperatue symbol code

NSString *degree = [NSString stringWithCString:symbol encoding:NSASCIIStringEncoding];

//when "degree" displayed on screen,messy code.

what kind of encoding should i use ? It seems that NSASCIIStringEncoding doesn't work.

or any other methods can helps to solove it?

هل كانت مفيدة؟

المحلول

Why go to all of this trouble? Just type in the degree symbol directly into your code?

NSString *temp = [NSString stringWithFormat:@"%d °C", someVal]; // Char U+00B0

Even better would be Unicode U+2103 () or U+2109 ().

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top