[問題] unicode文件中隱形字元?

看板C_and_CPP (C/C++)作者 (山豬元年革命志士)時間13年前 (2013/05/14 10:33), 編輯推噓1(101)
留言2則, 1人參與, 最新討論串1/1
開發平台(Platform): (Ex: VC++, GCC, Linux, ...) vs2012 額外使用到的函數庫(Library Used): (Ex: OpenGL, ...) mfc 問題(Question): 解析字幕文字時候遇到unicode的隱形字元 餵入的資料(Input): uni https://dl.dropboxusercontent.com/u/17190710/uni.txt ansi https://dl.dropboxusercontent.com/u/17190710/ansi.txt 預期的正確結果(Expected Output): 解讀時、分、秒時候 開始秒應該是02 錯誤結果(Wrong Output): 但因為中間藏有一個隱形字元 所以變成只抓到0,後面的欄位也跟著跑掉 程式碼(Code):(請善用置底文網頁, 記得排版) http://ideone.com/2jdcUC 補充說明(Supplement): 主要是 swscanf_s 解析buff時候被unicode中間的隱形字元打敗了 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 122.116.78.236

05/14 19:36, , 1F
hex dump 之後發現那個是 U+200B Zero-Width Space....orz
05/14 19:36, 1F

05/14 19:37, , 2F
既然你是直接讀 unicode 的話就把這個字給先濾掉再 scanf 吧
05/14 19:37, 2F
3q~看來沒有比較簡單的工具可以用 orz ※ 編輯: Achillean 來自: 122.116.78.236 (05/15 17:47)
文章代碼(AID): #1HaQ9wg7 (C_and_CPP)
文章代碼(AID): #1HaQ9wg7 (C_and_CPP)