윈도에서 코딩시
유니코드 적용해야 할때
#Define _UNICOE 을 하면
기존에 잘 컴파일 되던 플젝이 에러 투성이로 변하는 경우가 발생하져..ㅜㅜ

이런경우 당황하지 하지 마시고 모든 에러요인을 찾아다니면서 삽질을 하셔야 할껍니다.

아래와 같이 하시면 대략의 삽질은 면하지 않을까요..?? ^^
( 물론 직접 소스를 찾아가 수정을 가해야하는 부분이 발생하지만 아래와 같이 하시면 많은 부분의 수정요인이 사라지리라 생각합니다. )

1. 윈도 API를 사용한다.
sprintf 등 보다는 wsprintf등 과 같은 윈도에서 제공하는 함수나 MFC를 사용한다.
아무래도 UNICODE 설정만으로 한번에 변경하기 위해선 윈도에서 제공하는것을 써야할듯 싶습니다..^^

2. char * aa = NULL; 와 같은 char 사용시 TCHAR 을 사용한다.
ex> TCHAR *aa = NULL;

3. aa = "나텍스트"; 와 같이 텍스트 값을 사용할때는 _T("") 매크로를 사용한다.
ex> TCHAR aa[50] = { 0 , } , *a1 = NULL;
a1 = _T("나텍스트");
wsprintf( aa , _T("%s") , a1 );

3. 메모리 함수 memset , memcpy 등을 사용시 사용되는 스트링의 크기 ( 글자수가 아닌 ) 는 항상 ( sizeof(TCHAR) * ( 글자수 ) ) 로 한다.
ex> TCHAR aa[100];
memset( (BYTE*)aa , 0x00 , ( sizeof(TCHAR) * (100 ) ) );

4. 스트링 펑션을 쓸때는 _tcs... 으로 나가는 매크로를 사용한다.
ex> TCHAR *aa = "나도텍스트" , a1[50] , a2[50];
memset( (BYTE*)a1 , 0x00 , ( sizeof(TCHAR) * 50 ) );
memset( (BYTE*)a2 , 0x00 , ( sizeof(TCHAR) * 50 ) );

if ( 49 >=  _tcslen( aa ) )
{
_tcscpy( a1 , aa );
memcpy( (BYTE*)a2 , (BYTE*)aa , ( sizeof(TCHAR) * _tcslen(aa) ) );
}


** 아래는 4에서 말한 윈도용 매크로 함수들입니다.  참고하시기 바랍니당

1.       Formatted I/O

MACRO

ANSI

UNICODE

설명

_tprintf

printf

wprintf

 

_ftprintf

fprintf

fwprintf

 

_stprintf

sprint

swprintf

 

_sntprintf

_snprintf

_snwprintf

 

_vtprintf

vprintf

vwprintf

 

_vftprintf

vfprintf

vfwprintf

 

_vstprintf

vsprintf

vswprintf

 

_vsntprintf

_vsnprintf

_vsnwprintf

 

_tscanf

scanf

wscanf

 

_ftscanf

fscanf

fwscanf

 

_stscanf

sscanf

swscanf

 

 

2.       Formatted I/O

MACRO

ANSI

UNICODE

설명

_fgettc

fgetc

fgetwc

 

_fgetts

fgets

fgetwc

 

_fputtc

fputc

fputwc

 

_fputts

fputs

fputws

 

_gettc

getc

getwc

 

_gettchar

getchar

getwchar

 

_getts

gets

_getws

 

_puttc

putc

putwc

 

_puttchar

putchar

putwchar

 

_putts

puts

_putws

 

_ungettc

ungetc

ungetwc

 

 

3.       Stdio function

MACRO

ANSI

UNICODE

설명

_tfopen

 

_wfopen

 

_tfreopen

 

_wfreopen

 

 

4.       String conversion function

MACRO

ANSI

UNICODE

설명

_tcstod

strtod

wcstod

 

_tcstol

strtol

wcstol

 

_tcstoul

strtoul

wcstoul

 

_itot

_itoa

_itow

 

_ltot

_ltoa

_ltow

 

_ultot

_ultoa

_ultow

 

_ttoi

atoi

_wtoi

 

_ttol

atol

_wtol

 

 

5.       String function

MACRO

ANSI

UNICODE

설명

_tcscat

strcat

wcscat

 

_tcschr

strchr

wcschr

 

_tcscmp

strcmp

wcscmp

 

_tcscpy

strcpy

wcscpy

 

_tcscspn

strcspn

wcscspn

 

_tcslen

strlen

wcslen

 

_tcsclen

strlen

wcslen

 

_tcsncat

strncat

wcsncat

 

_tcsnccat

strncat

wcsncat

 

_tcsnccmp

strncmp

wcsncmp

 

_tcsncmp

strncmp

wcsncmp

 

_tcsncpy

strncpy

wcsncpy

 

_tcsnccpy

strncpy

wcsncpy

 

_tcspbrk

strpbrk

wcspbrk

 

_tcsrchr

strrchr

wcsrchr

 

_tcsspn

strspn

wcsspn

 

_tcsstr

strstr

wcsstr

 

_tcstok

strtok

wcstok

 

_tcsdup

_strdup

_wcsdup

 

_tcsicmp

_stricmp

_wcsicmp

 

_tcsncicmp

_strnicmp

_wcsnicmp

 

_tcsnicmp

_strnicmp

_wcsnicmp

 

_tcsnset

_strnset

_wcsnset

 

_tcsncset

_strnset

_wcsnset

 

_tcsrev

_strrev

_wcsrev

 

_tcsset

_strset

_wcsset

 

_tcslwr

_strlwr

_wcslwr

 

_tcsupr

_strupr

_wcsupr

 

 

6.       ctype function

MACRO

ANSI

UNICODE

설명

_istalpha

isalpha

iswalpha

 

_istupper

isupper

iswupper

 

_istlower

islower

iswlower

 

_istdigit

isdigit

iswdigit

 

_istxdigit

isxdigit

iswxdigit

 

_istspace

isspace

iswspace

 

_istpunct

ispunct

iswpunct

 

_istalnum

isalnum

iswalnum

 

_istprint

isprint

iswprint

 

_istgraph

isgraph

iswgraph

 

_istcntrl

iscntrl

iswcntrl

 

_istascii

isascii

iswascii

 

_totupper

toupper

towupper

 

_totlower

tolower

towlower

 


http://demo.initech.com/?document_srl=4077



Standard CRT function

StrSafe Function

strcat

StringCchCat, StringCchCatEx, StringCbCat, StringCbCatEx

strcmp

(no equivalent function)

strcpy

StringCchCopy, StringCchCopyEx, StringCbCopy, StringCbCopyEx

strlen

StringCchLength, StringCbLength

Standard CRT function

StrSafe Function

sprintf

StringCchPrintf, StringCchPrintfEx, StringCbPrintf, StringCbPrintfEx

vsprintf

StringCchVPrintf, StringCchVPrintfEx, StringCbVPrintf, StringCbVPrintfEx

 

 

Data Types

ANSI

Wide

TCHAR

char

wchar_t

_TCHAR

_finddata_t

_wfinddata_t

_tfinddata_t

__finddata64_t

__wfinddata64_t

_tfinddata64_t

_finddatai64_t

_wfinddatai64_t

_tfinddatai64_t

int

wint_t

_TINT

signed char

wchar_t

_TSCHAR

unsigned char

wchar_t

_TUCHAR

char

wchar_t

_TXCHAR

 

L

_T or _TEXT

LPSTR
(char *)

LPWSTR
(wchar_t *)

LPTSTR
(_TCHAR *)

LPCSTR
(const char *)

LPCWSTR
(const wchar_t *)

LPCTSTR
(const _TCHAR *)

LPOLESTR
(for OLE)

LPWSTR

LPTSTR

 

 

 

TCHAR String Functions

ANSI

Wide

TCHAR

_access

_waccess

_taccess

_atoi64

_wtoi64

_tstoi64

_atoi64

_wtoi64

_ttoi64

_cgets

_cgetws

cgetts

_chdir

_wchdir

_tchdir

_chmod

_wchmod

_tchmod

_cprintf

_cwprintf

_tcprintf

_cputs

_cputws

_cputts

_creat

_wcreat

_tcreat

_cscanf

_cwscanf

_tcscanf

_ctime64

_wctime64

_tctime64

_execl

_wexecl

_texecl

_execle

_wexecle

_texecle

_execlp

_wexeclp

_texeclp

_execlpe

_wexeclpe

_texeclpe

_execv

_wexecv

_texecv

_execve

_wexecve

_texecve

_execvp

_wexecvp

_texecvp

_execvpe

_wexecvpe

_texecvpe

_fdopen

_wfdopen

_tfdopen

_fgetchar

_fgetwchar

_fgettchar

_findfirst

_wfindfirst

_tfindfirst

_findnext64

_wfindnext64

_tfindnext64

_findnext

_wfindnext

_tfindnext

_findnexti64

_wfindnexti64

_tfindnexti64

_fputchar

_fputwchar

_fputtchar

_fsopen

_wfsopen

_tfsopen

_fullpath

_wfullpath

_tfullpath

_getch

_getwch

_gettch

_getche

_getwche

_gettche

_getcwd

_wgetcwd

_tgetcwd

_getdcwd

_wgetdcwd

_tgetdcwd

_ltoa

_ltow

_ltot

_makepath

_wmakepath

_tmakepath

_mkdir

_wmkdir

_tmkdir

_mktemp

_wmktemp

_tmktemp

_open

_wopen

_topen

_popen

_wpopen

_tpopen

_putch

_putwch

_puttch

_putenv

_wputenv

_tputenv

_rmdir

_wrmdir

_trmdir

_scprintf

_scwprintf

_sctprintf

_searchenv

_wsearchenv

_tsearchenv

_snprintf

_snwprintf

_sntprintf

_snscanf

_snwscanf

_sntscanf

_sopen

_wsopen

_tsopen

_spawnl

_wspawnl

_tspawnl

_spawnle

_wspawnle

_tspawnle

_spawnlp

_wspawnlp

_tspawnlp

_spawnlpe

_wspawnlpe

_tspawnlpe

_spawnv

_wspawnv

_tspawnv

_spawnve

_wspawnve

_tspawnve

_spawnvp

_wspawnvp

_tspawnvp

_spawnvpe

_wspawnvpe

_tspawnvpe

_splitpath

_wsplitpath

_tsplitpath

_stat64

_wstat64

_tstat64

_stat

_wstat

_tstat

_stati64

_wstati64

_tstati64

_strdate

_wstrdate

_tstrdate

_strdec

_wcsdec

_tcsdec

_strdup

_wcsdup

_tcsdup

_stricmp

_wcsicmp

_tcsicmp

_stricoll

_wcsicoll

_tcsicoll

_strinc

_wcsinc

_tcsinc

_strlwr

_wcslwr

_tcslwr

_strncnt

_wcsncnt

_tcsnbcnt

_strncnt

_wcsncnt

_tcsnccnt

_strncnt

_wcsncnt

_tcsnccnt

_strncoll

_wcsncoll

_tcsnccoll

_strnextc

_wcsnextc

_tcsnextc

_strnicmp

_wcsnicmp

_tcsncicmp

_strnicmp

_wcsnicmp

_tcsnicmp

_strnicoll

_wcsnicoll

_tcsncicoll

_strnicoll

_wcsnicoll

_tcsnicoll

_strninc

_wcsninc

_tcsninc

_strnset

_wcsnset

_tcsncset

_strnset

_wcsnset

_tcsnset

_strrev

_wcsrev

_tcsrev

_strset

_wcsset

_tcsset

_strspnp

_wcsspnp

_tcsspnp

_strtime

_wstrtime

_tstrtime

_strtoi64

_wcstoi64

_tcstoi64

_strtoui64

_wcstoui64

_tcstoui64

_strupr

_wcsupr

_tcsupr

_tempnam

_wtempnam

_ttempnam

_ui64toa

_ui64tow

_ui64tot

_ultoa

_ultow

_ultot

_ungetch

_ungetwch

_ungettch

_unlink

_wunlink

_tunlink

_utime64

_wutime64

_tutime64

_utime

_wutime

_tutime

_vscprintf

_vscwprintf

_vsctprintf

_vsnprintf

_vsnwprintf

_vsntprintf

asctime

_wasctime

_tasctime

atof

_wtof

_tstof

atoi

_wtoi

_tstoi

atoi

_wtoi

_ttoi

atol

_wtol

_tstol

atol

_wtol

_ttol

character compare

Maps to macro or inline function

_tccmp

character copy

Maps to macro or inline function

_tccpy

character length

Maps to macro or inline function

_tclen

ctime

_wctime

_tctime

fgetc

fgetwc

_fgettc

fgets

fgetws

_fgetts

fopen

_wfopen

_tfopen

fprintf

fwprintf

_ftprintf

fputc

fputwc

_fputtc

fputs

fputws

_fputts

freopen

_wfreopen

_tfreopen

fscanf

fwscanf

_ftscanf

getc

getwc

_gettc

getchar

getwchar

_gettchar

getenv

_wgetenv

_tgetenv

gets

getws

_getts

isalnum

iswalnum

_istalnum

isalpha

iswalpha

_istalpha

isascii

iswascii

_istascii

iscntrl

iswcntrl

_istcntrl

isdigit

iswdigit

_istdigit

isgraph

iswgraph

_istgraph

islead (Always FALSE)

(Always FALSE)

_istlead

isleadbyte (Always FALSE)

isleadbyte (Always FALSE)

_istleadbyte

islegal (Always TRUE)

(Always TRUE)

_istlegal

islower

iswlower

_istlower

isprint

iswprint

_istprint

ispunct

iswpunct

_istpunct

isspace

iswspace

_istspace

isupper

iswupper

_istupper

isxdigit

iswxdigit

_istxdigit

main

wmain

_tmain

perror

_wperror

_tperror

printf

wprintf

_tprintf

putc

putwc

_puttc

putchar

putwchar

_puttchar

puts

_putws

_putts

remove

_wremove

_tremove

rename

_wrename

_trename

scanf

wscanf

_tscanf

setlocale

_wsetlocale

_tsetlocale

sprintf

swprintf

_stprintf

sscanf

swscanf

_stscanf

strcat

wcscat

_tcscat

strchr

wcschr

_tcschr

strcmp

wcscmp

_tcscmp

strcoll

wcscoll

_tcscoll

strcpy

wcscpy

_tcscpy

strcspn

wcscspn

_tcscspn

strerror

_wcserror

_tcserror

strftime

wcsftime

_tcsftime

strlen

wcslen

_tcsclen

strlen

wcslen

_tcslen

strncat

wcsncat

_tcsncat

strncat

wcsncat

_tcsnccat

strncmp

wcsncmp

_tcsnccmp

strncmp

wcsncmp

_tcsncmp

strncpy

wcsncpy

_tcsnccpy

strncpy

wcsncpy

_tcsncpy

strpbrk

wcspbrk

_tcspbrk

strrchr

wcsrchr

_tcsrchr

strspn

wcsspn

_tcsspn

strstr

wcsstr

_tcsstr

strtod

wcstod

_tcstod

strtok

wcstok

_tcstok

strtol

wcstol

_tcstol

strtoul

wcstoul

_tcstoul

strxfrm

wcsxfrm

_tcsxfrm

system

_wsystem

_tsystem

tmpnam

_wtmpnam

_ttmpnam

tolower

towlower

_totlower

toupper

towupper

_totupper

ungetc

ungetwc

_ungettc

vfprintf

vfwprintf

_vftprintf

vprintf

vwprintf

_vtprintf

vsprintf

vswprintf

_vstprintf

WinMain

wWinMain

_tWinMain

 

'library > CRT' 카테고리의 다른 글

errno  (0) 2011.01.08
유니코드를 위한 함수  (0) 2011.01.08
시간과 날짜와 관련된 라이브러리 함수들  (0) 2010.12.15
문자열 함수들의 버퍼 체크 방법 차이  (0) 2010.11.24
디버그 시 malloc 메모리 누수 탐지  (0) 2010.07.16
블로그 이미지

란마12

,