티스토리 뷰

C언어

UTF-8 -> UNICODE -> CP949

바람사탕 2024. 3. 9. 23:45
반응형

//UTF-8 -> UNICODE -> CP949
void strcpy_UTF8(char *buf,char *s)//max=1024
{
    if(buf)if(s)
     {
          wchar_t bufw[1024];
          MultiByteToWideChar(CP_UTF8,0,s, -1,bufw,1024);
          WideCharToMultiByte(CP_ACP,0,bufw, -1,buf,1024,NULL,NULL);
     }
}

 

 

 

 

 

 

 

 

 

 

void myprintf(char *fmt,...)
{
char buf[4096]; // 버퍼 크기는 필요에 따라 조절 가능
    va_list args;
    va_start(args, fmt);
    vsprintf(buf, fmt, args);
    va_end(args);
    OutputDebugString(buf);
Sleep(10);
}

void strcpy(wchar_t *buf,char *s)
{
int nLen = MultiByteToWideChar(CP_ACP,
0,
s, -1,
NULL,
NULL);

MultiByteToWideChar(CP_ACP,
0,
s, -1,
buf,
nLen);
}
void strcpy(char *buf,wchar_t *s)//max=1024
{
if(buf)if(s)
{
WideCharToMultiByte(CP_ACP,
0,
s, -1,
buf,1024,
NULL,
NULL);
}
}

void strcat(wchar_t *buf,char *s)
{
if(buf)if(s)
{
while(*buf)buf++;
int nLen = MultiByteToWideChar(CP_ACP,
0,
s, -1,
NULL,
NULL);

MultiByteToWideChar(CP_ACP,
0,
s, -1,
buf,
nLen);
}
}
void strcat(char *buf,wchar_t *s)//max=1024
{
if(buf)if(s)
{
WideCharToMultiByte(CP_ACP,
0,
s, -1,
buf,1024,
NULL,
NULL);
}
}

void GUID_to_str(GUID *a, char *buf)
{
    sprintf(buf, "{%08lX-%04hX-%04hX-%02hhX%02hhX-%02hhX%02hhX%02hhX%02hhX%02hhX%02hhX}",
            a->Data1, a->Data2, a->Data3,
            a->Data4[0], a->Data4[1], a->Data4[2], a->Data4[3],
            a->Data4[4], a->Data4[5], a->Data4[6], a->Data4[7]);
}


//컨트롤의 위치는 이동하지 않고 너비와 높이만 부모 윈도우의 클라이언트 크기에 맞춘다.
BOOL ControlWindow_FitSize_to_ParentWindow_DoseNotMove(HWND hWnd_Control,HWND hWnd_Parent)
{
RECT r;
WINDOWPLACEMENT wp;

if(hWnd_Control)
{
if(::GetClientRect(hWnd_Parent,&r))
{
wp.length=sizeof(wp);
if(::GetWindowPlacement(hWnd_Control,&wp))
{
return ::MoveWindow(hWnd_Control,wp.rcNormalPosition.left,wp.rcNormalPosition.top,
  r.right-wp.rcNormalPosition.left,r.bottom-wp.rcNormalPosition.top,TRUE);
}
}
}
return FALSE;
}



char Log_buf[1024*4];
void Log_puts(char *s)
{
if(strcmp(Log_buf,s))
{
::SetWindowText(hwnd_IDC_EDIT1,s);
strcpy(Log_buf,s);
myprintf(s);
Beep(1000,100);
}
}

반응형
반응형
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
TAG
more
«   2024/05   »
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
글 보관함