我試圖檢測字符â
在Objective C中的字符串,似乎無法讓它工作。當它最終顯示在屏幕上時它會顯示一個子彈點,所以也許這就是爲什麼我無法檢測到它?檢測â在一個字符串
在iOS 10中,這些項目符號顯示比他們應該更大,所以我需要找到每個這些字符的範圍,並使它們縮小几個尺寸。我已經試過如下:
[inputString contains:@"â"]
[inputString contains:@"•"]
[inputString contains:@"\u00b7"]
[inputString contains:@"\u2022"]
我感興趣的最多的是當我從API響應複製並粘貼正是一個:[inputString contains:@"â "]
。這個字符串中實際上有4或5個空格,但是從JSON粘貼時它們會被截斷 - 我不確定爲什麼,但我覺得這與我無法識別字符串包含該字符有關。
關於如何正確處理這個角色的任何想法?
編輯:一些細節,下面是會從API發回的字符串:
â All of your exclusive deals in one place\nâ More deals matched specifically to you\nâ Get alerts to know when new deals are available or your saved deals are expiring"
我發現了一些奇怪的還有,當我編輯的響應和更那些年代的帽子加,他們會轉移到項目符號點,但是當我將它們添加到代碼中的字符串中時,它們顯示爲簡單的項目符號點。也許他們正在編碼?雖然我在代碼中看不到任何可能發生的情況,但我對這裏發生的事情有點困惑。
編輯2:這是該行的一個hexdump都可以,這可能是更有用一些你是不是比我:
000026c0 6e 74 65 6e 74 22 3a 20 22 e2 97 8f 20 41 6c 6c |ntent": "... All|
000026d0 20 6f 66 20 79 6f 75 72 20 65 78 63 6c 75 73 69 | of your exclusi|
000026e0 76 65 20 64 65 61 6c 73 20 69 6e 20 6f 6e 65 20 |ve deals in one |
000026f0 70 6c 61 63 65 5c 6e e2 97 8f 20 4d 6f 72 65 20 |place\n... More |
00002700 64 65 61 6c 73 20 6d 61 74 63 68 65 64 20 73 70 |deals matched sp|
00002710 65 63 69 66 69 63 61 6c 6c 79 20 74 6f 20 79 6f |ecifically to yo|
00002720 75 5c 6e e2 97 8f 20 47 65 74 20 61 6c 65 72 74 |u\n... Get alert|
00002730 73 20 74 6f 20 6b 6e 6f 77 20 77 68 65 6e 20 6e |s to know when n|
00002740 65 77 20 64 65 61 6c 73 20 61 72 65 20 61 76 61 |ew deals are ava|
00002750 69 6c 61 62 6c 65 20 6f 72 20 79 6f 75 72 20 73 |ilable or your s|
00002760 61 76 65 64 20 64 65 61 6c 73 20 61 72 65 20 65 |aved deals are e|
00002770 78 70 69 72 69 6e 67 22 2c 0d 0a 20 20 20 20 22 |xpiring",.. "|
你能顯示你的迴應字符串嗎? –
你看過正常化的字符串嗎? https://www.objc.io/issues/9-strings/unicode/#normalization-forms – Mats
我試着註銷四種形式的規範化字符串,他們都仍然成爲我的控制檯中的子彈點 –