[問題] - (NSString *)description 中文印不出來

看板MacDev作者 (鼠伯特)時間13年前 (2011/11/20 01:16), 編輯推噓2(205)
留言7則, 3人參與, 最新討論串1/3 (看更多)
obj-c 新手請問 我有一個 instance variable type 是 id: @interface A : NSObject @property (retain) id item; @end 然後我幫這個 class implement 一個簡單的 description: @implementation A @synthesize item; - (NSString *)description { return [NSString stringWithFormat:@"(%@)", self.item]; } @end 我把一個 NSString assign 給 id 這個 type 的 instance variable 然後我想印 A 這種 object: A *a = [[A alloc] init]; a.item = @"8月"; NSLog(@"%@", a); 印出來的東西變成類似這樣: "(8\U6708)" 請問這是為什麼呢? -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 114.37.145.173 ※ 編輯: ratbert 來自: 114.37.145.173 (11/20 01:17)

11/20 02:47, , 1F
月的
11/20 02:47, 1F

11/20 02:50, , 2F
UTF8編碼是U6708
11/20 02:50, 2F

11/20 11:11, , 3F
我的意思是說, 要怎麼讓他印出中文而不是印出UTF8咧?
11/20 11:11, 3F

11/20 14:22, , 4F
我剛剛試了一下結果很正常...
11/20 14:22, 4F

11/20 14:25, , 5F
https://gist.github.com/1379881 出來正常的中文
11/20 14:25, 5F

11/20 17:18, , 6F
urh... 我剛試一下我這個簡化版的 code 結果也是正常...
11/20 17:18, 6F

11/20 17:19, , 7F
我再回頭研究一下原本的 code
11/20 17:19, 7F
文章代碼(AID): #1En-Hsb9 (MacDev)
文章代碼(AID): #1En-Hsb9 (MacDev)