[iOS] 移除看不見的字元 (Remove Invisible Character)
「看不到的不代表不存在~」,寫程式也會遇到這個現象!我在比較日期字串時,發現明明兩者都是2018-07-17,卻被判斷出不一樣!?
好在透過取得字串長度,才發現真有看不見的字元「\0」!
(lldb) po firmwareVersionLabel.text.length
32(lldb) po newVersionLabel.text.length
10
實際上2018-07-17只有10個字元,而韌體回傳卻有32個字元,於是知道後面看不到的字元共有22個。
![[iOS] 移除看不見的字元 (Remove Invisible Character).png](https://cg2010studio.com/wp-content/uploads/2018/08/ios-e7a7bbe999a4e79c8be4b88de8a68be79a84e5ad97e58583-remove-invisible-character.png?w=540)
HappyMan・迴響