2009-07-13 7 views
1

웹 페이지에서 일부 샘플 코드의 복사본으로 시작된 소스 코드 파일이 있습니다. Windows에서 작성 및 편집되었으며 문제없이 컴파일되었습니다.텍스트 파일에서 특수 문자를 제거하는 방법은 무엇입니까? (* nix)

는하지만 맥에서 내가 좋아하는, 모호한 오류의 부하를 얻을 : 문제가 일부 특수 문자처럼

../MyProgram.cpp:1: error: stray '\255' in program 
../MyProgram.cpp:1: error: stray '\254' in program 
../MyProgram.cpp:1: error: stray '#' in program 
../MyProgram.cpp:3:4: error: invalid preprocessing directive #i 
../MyProgram.cpp:5:4: error: invalid preprocessing directive #i 
../MyProgram.cpp:7:4: error: invalid preprocessing directive #i 
../MyProgram.cpp:23: error: missing terminating ' character 
../MyProgram.cpp:369:6: error: invalid preprocessing directive #i 
../MyProgram.cpp:371:8: error: invalid preprocessing directive #i 
../MyProgram.cpp:375:8: error: invalid preprocessing directive #e 
../MyProgram.cpp:381:8: error: invalid preprocessing directive #e 
../MyProgram.cpp:383:6: error: invalid preprocessing directive #e 
../MyProgram.cpp:385:8: error: invalid preprocessing directive #i 
../MyProgram.cpp:389:8: error: invalid preprocessing directive #e 
../MyProgram.cpp:1: error: 'i' does not name a type 
../MyProgram.cpp:53: error: 'V' does not name a type 
../MyProgram.cpp:75: error: 'v' does not name a type 
../MyProgram.cpp:157: error: 'l' does not name a type 
../MyProgram.cpp:169: error: 'l' does not name a type 
../MyProgram.cpp:187: error: 'i' does not name a type 
../MyProgram.cpp:197: error: 'v' does not name a type 

보인다.

* nix 명령 줄을 사용하여 어떻게 제거 할 수 있습니까?

+0

많은 유닉스 배포판에는/usr/bin에 있어야하는 dos2unix 유틸리티가 있습니다. OSX에 대한 확신이 없습니다 ... – Alex

+0

http://dos2unix.darwinports.com/ – Jon

+2

문제는 특수 문자가 아닙니다. 그것은 UTF-16입니다 : FFFE는 당신의 힌트입니다. –

답변

9

파일이 UTF-16으로 저장된 것처럼 보입니다. 텍스트 편집기에서이를 열고 UTF-8로 다시 인코딩하면 문제가 해결됩니다.

+0

맞습니다. 이제 UTF-16으로 고정되었습니다. – Maleev

0

원래 \ 255 & \ 254 문자를 제거하는 방법을 말씀 드렸지만 의견에 동의합니다. 유니 코드입니다. 시도

iconv -f iso-8859-1 -t utf-8 infile > outfile 

iso-8859-1은 추측에 불과합니다.

관련 문제