프로그래밍/라이브러리
[Win32 API] WCS 과 MBS간의 변환
써드아이
2008. 2. 6. 20:23
일반적인지는 모르겠지만 윈도 프로그래밍에서
유니코드 문자열은 wide charater (wcs) 라고 부르고
ascii 코드 문자열은 multi byte character (mbs) 라고 부르는 듯 하다.
char * 형의 문자열을 출력 함수의 인자로 사용하니까 Data Abort 에러가 발생한다.
이걸 몰라서 하루동안 삽질을.. ㅠ.ㅠ
두 코드의 문자열을 서로 변환하기 위해서는 다음과 같은 함수를 사용하면 된다.
size_t mbstowcs( wchar_t *wcstr, const char *mbstr, size_t count );
wcstr - The address of a sequence of wide characters
mbstr - The address of a sequence of multibyte characters
count - The number of multibyte characters to convert
size_t wcstombs( char *mbstr, const wchar_t *wcstr, size_t count );
mbstr - The address of a sequence of multibyte characters
wcstr - The address of a sequence of wide characters
count - The maximum number of bytes that can be stored in the multibyte output string
유니코드 문자열은 wide charater (wcs) 라고 부르고
ascii 코드 문자열은 multi byte character (mbs) 라고 부르는 듯 하다.
char * 형의 문자열을 출력 함수의 인자로 사용하니까 Data Abort 에러가 발생한다.
이걸 몰라서 하루동안 삽질을.. ㅠ.ㅠ
두 코드의 문자열을 서로 변환하기 위해서는 다음과 같은 함수를 사용하면 된다.
size_t mbstowcs( wchar_t *wcstr, const char *mbstr, size_t count );
wcstr - The address of a sequence of wide characters
mbstr - The address of a sequence of multibyte characters
count - The number of multibyte characters to convert
size_t wcstombs( char *mbstr, const wchar_t *wcstr, size_t count );
mbstr - The address of a sequence of multibyte characters
wcstr - The address of a sequence of wide characters
count - The maximum number of bytes that can be stored in the multibyte output string