내배캠/TIL

25.01.13 (월)

동그래님 2025. 1. 13. 11:36

UTF-8 인코딩 문제

 

"The file contains a character that cannot be represented in the current code page (949). Save the file in Unicode format to prevent data loss "  오류 발생..

 

한글 문자열이 포함되어있는 프로젝트를 빌드했을 때, 다음과 같은 오류가 발생하였다. 물론 UTF-8 with out signature로 저장했는데도 말이다..

 

Visual Studio와 컴파일러 설정 불일치

이는 Visual Studio에서 저장한 파일 인코딩(UTF-8)과 컴파일러가 사용하는 기본 인코딩 설정이 불일치하여 경고가 발생할 수 있다.

 

해결 방법:

  • 컴파일러에 UTF-8 명시적으로 지정하기
    1. Visual Studio에서 프로젝트 속성으로 이동.
    2. Configuration PropertiesC/C++Command Line을 선택.
    3. Additional Options에 "/utf-8" 을 추가하여 UTF-8 인코딩을 강제한다.

 

 

빌드 시, 오류가 발생하지 않는 것을 확인할 수 있다.

 

 


 

CodeCata

 

https://dong-grae.tistory.com/108

 

숫자 짝꿍

https://school.programmers.co.kr/learn/courses/30/lessons/131128  *초기 작성 코드#include #include #include using namespace std;string solution(string X, string Y) { string answer = ""; char target; sort(X.begin(), X.end(), greater()); sort(Y.begin

dong-grae.tistory.com