반응형

BOM : Byte Order Mark

보통 UTF-8 파일 맨 앞부분에 EE BB BF 값이 들어가 파일 시스템 관리할 때 귀찮게 구는 녀석입니다.

 

찾아보니 without BOM 형식으로 저장하는 방법이 있어 공유합니다.

 

visual studio에 with BOM으로 설정되어있는 파일을 열어줍니다.

 

파일 → 다른 이름으로 저장

저장 고급 옵션 → 인코딩하여 저장

유니코드(서명 없는 UTF-8) - 코드 페이지 65001 설정 후 저장하면 끝입니다.

 

if (fopen_s(&contactsFile, CONTACTS_PATH, "r+, ccs=UNICODE") != 0) {
	if (fopen_s(&contactsFile, CONTACTS_PATH, "w+, ccs=UNICODE") != 0)
		_OccurError(errno, __FILE__, __LINE__);
}

해당 코드는 C언어 입니다.

C언어 안쓰시면 지나가세요.

 

ccs=UTF-8로 설정하면 with BOM으로 저장되니 ccs=UNICODE로 설정해줘야 합니다.

 

참고 자료


https://learn.microsoft.com/ko-kr/cpp/c-runtime-library/reference/fopen-wfopen?view=msvc-170

 

fopen, _wfopen

자세한 정보: fopen, _wfopen

learn.microsoft.com

https://stackoverflow.com/questions/5406172/utf-8-without-bom

 

UTF-8 without BOM

I have javascript files that I need them to be saved in UTF-8 (without BOM), every time I convert them to the correct format in Notepad++, they are reverted back to UTF-8 with BOM when I open them in

stackoverflow.com

 

 

반응형
원피스는 실존하다